Switch to C++, remove externs, fix warnings

This commit is contained in:
Aadi Desai 2023-05-12 19:53:27 +01:00
parent d1884c6ac8
commit d057017052
No known key found for this signature in database
6 changed files with 10 additions and 16 deletions

View file

@ -1,7 +1,6 @@
#include <generated/csr.h> #include <generated/csr.h>
#include <stdio.h> #include <stdio.h>
extern "C" void audio(int);
void audio(int v) { void audio(int v) {
audio_targ_write(v); audio_targ_write(v);
} }

View file

@ -15,13 +15,12 @@
_=x; \ _=x; \
x -= mul*y>>shift; \ x -= mul*y>>shift; \
y += mul*_>>shift; \ y += mul*_>>shift; \
_ = 3145728-x*x-y*y>>11; \ _ = (3145728-x*x-y*y)>>11; \
x = x*_>>10; \ x = x*_>>10; \
y = y*_>>10; y = y*_>>10;
signed char b[1760], z[1760]; signed char b[1760], z[1760];
void donut(void);
void donut(void) { void donut(void) {
int sA=1024,cA=0,sB=1024,cB=0,_; int sA=1024,cA=0,sB=1024,cB=0,_;
for (;;) { for (;;) {
@ -43,7 +42,7 @@ void donut(void) {
x7 = cj*si >> 10, x7 = cj*si >> 10,
x = 40 + 30*(cB*x1 - sB*x4)/x6, x = 40 + 30*(cB*x1 - sB*x4)/x6,
y = 12 + 15*(cB*x4 + sB*x1)/x6, y = 12 + 15*(cB*x4 + sB*x1)/x6,
N = (-cA*x7 - cB*((-sA*x7>>10) + x2) - ci*(cj*sB >> 10) >> 10) - x5 >> 7; N = (((-cA*x7 - cB*((-sA*x7>>10) + x2) - ci*(cj*sB >> 10)) >> 10) - x5) >> 7;
int o = x + 80 * y; int o = x + 80 * y;
signed char zz = (x6-K2)>>15; signed char zz = (x6-K2)>>15;

View file

@ -1,6 +1,5 @@
#include <stdio.h> #include <stdio.h>
void helloc(void);
void helloc(void) { void helloc(void) {
printf("C: Hello, world!\n"); printf("C: Hello, world!\n");
} }

View file

@ -1,7 +1,5 @@
#include <stdio.h> #include <stdio.h>
extern "C" void hellocpp(void); void hellocpp(void) {
void hellocpp(void) printf("C++: Hello, world!\n");
{
printf("C++: Hello, world!\n");
} }

View file

@ -1,7 +1,6 @@
#include <generated/csr.h> #include <generated/csr.h>
#include <stdio.h> #include <stdio.h>
extern "C" void leds(int);
void leds(int v) { void leds(int v) {
leds_out_write(v); leds_out_write(v);
} }

View file

@ -17,7 +17,7 @@
static char *readstr(void) { static char *readstr(void) {
char c[2]; char c[2];
static char s[64]; static char s[64];
static int ptr = 0; static unsigned int ptr = 0;
if (readchar_nonblock()) { if (readchar_nonblock()) {
c[0] = getchar(); c[0] = getchar();
@ -144,7 +144,7 @@ static void led_cmd(void) {
#endif #endif
#ifdef CSR_LEDS_BASE #ifdef CSR_LEDS_BASE
extern "C" void leds(int); void leds(int);
static void leds_cmd(char **val) { static void leds_cmd(char **val) {
int value = (int)strtol(get_token(val), NULL, 0); int value = (int)strtol(get_token(val), NULL, 0);
@ -153,7 +153,7 @@ static void leds_cmd(char **val) {
} }
#endif #endif
#ifdef CSR_AUDIO_BASE #ifdef CSR_AUDIO_BASE
extern "C" void audio(int); void audio(int);
static void audio_cmd(char **val) { static void audio_cmd(char **val) {
int value = (int)strtol(get_token(val), NULL, 0); int value = (int)strtol(get_token(val), NULL, 0);
@ -162,21 +162,21 @@ static void audio_cmd(char **val) {
} }
#endif #endif
extern "C" void donut(void); void donut(void);
static void donut_cmd(void) { static void donut_cmd(void) {
printf("Donut demo...\n"); printf("Donut demo...\n");
donut(); donut();
} }
extern "C" void helloc(void); void helloc(void);
static void helloc_cmd(void) { static void helloc_cmd(void) {
printf("Hello C demo...\n"); printf("Hello C demo...\n");
helloc(); helloc();
} }
extern "C" void hellocpp(void); void hellocpp(void);
static void hellocpp_cmd(void) { static void hellocpp_cmd(void) {
printf("Hello C++ demo...\n"); printf("Hello C++ demo...\n");