pervognsen / bitwise

Bitwise is an educational project where we create the software/hardware stack for a computer from scratch.
Other
5.13k stars 213 forks source link

Missing stdio_osx.ion & time_osx.ion for macOS #46

Closed stevetranby closed 6 years ago

stevetranby commented 6 years ago

[edited]

The ion binary compiles fine with gcc main.c

However, the Ion tests don't compile unless I duplicate linux files:

cp stdio_linux.ion stdio_osx.ion
cp time_linux.ion time_osx.ion

Also, on OSX (10.13 High Sierra, XCode 9.3) clock_t is defined as unsigned long:

@foreign typedef time_t = long;
@foreign typedef clock_t = ulong;

from mac system headers

typedef unsigned long       __darwin_clock_t;   /* clock() */
typedef long                __darwin_time_t;    /* time() */
typedef __darwin_time_t     time_t;
typedef __darwin_clock_t    clock_t;

stdio_osx.ion:

@foreign const _IOFBF = 0;
@foreign const _IOLBF = 1;
@foreign const _IONBF = 2;

@foreign const BUFSIZ       = 1024;
@foreign const FILENAME_MAX = 1024;
@foreign const FOPEN_MAX    = 20;
@foreign const TMP_MAX      = 308915776;
@foreign const L_tmpnam     = 1024;

from mac system headers

#define _IOFBF  0       /* setvbuf should set fully buffered */
#define _IOLBF  1       /* setvbuf should set line buffered */
#define _IONBF  2       /* setvbuf should set unbuffered */

#define BUFSIZ  1024    /* size of buffer used by setbuf */

                                /* must be == _POSIX_STREAM_MAX <limits.h> */
#define FOPEN_MAX   20          /* must be <= OPEN_MAX <sys/syslimits.h> */
#define FILENAME_MAX    1024    /* must be <= PATH_MAX <sys/syslimits.h> */

/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
#ifndef _ANSI_SOURCE
#define P_tmpdir    "/var/tmp/"
#endif
#define L_tmpnam    1024        /* XXX must be == PATH_MAX */
#define TMP_MAX     308915776
pervognsen commented 6 years ago

Thanks for reporting it. Could you maybe do a PR with the proposed, tested changes? Right now I unfortunately don't have a way to test things on OS X myself.

stevetranby commented 6 years ago

I will try to continue testing macOS as the project progresses.