Skip to content

Commit 36a6feb

Browse files
authored
Merge pull request #328 from jayrm/freebsd
Updates for Darwin, FreeBSD i386 and amd64
2 parents e1d15cb + 8835777 commit 36a6feb

38 files changed

+715
-61
lines changed

changelog.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ Version 1.09.0
99
- crt headers: add const qualifiers in crt/stdio.bi, crt/sys/stat.bi, crt/wchar.bi
1010
- crt headers: add const qualifiers in crt/sys/win32/stat.bi, crt/win32/stdio.bi
1111
- github #325, #326: fbc: internal changes for string processing functions
12+
- fbc-tests: xargs on freebsd does not support the '-a filename' option, use 'cat filename | xargs' instead
13+
- fbc: gen gcc: allow compiling with GCC 4.5 and older, by avoiding -Wno-unused-but-set-variable (TeeEmCee)
14+
- fbc: internal function fbcQueryGcc() to ask gcc for the correct as & ld to use (TeeEmCee)
15+
- rtlib: freebsd: minimum thread stacksize 8192 KiB
1216

1317
[added]
1418
- fbc: add '-z fbrt' command line option to link against libfbrt*.a instead of libfb*.a
1519
- makefile: add target for fbrt, fb runtime library written in fbc. Bulid libfbrt*.a and merge any missing object modules from libfb*.a
1620
- github #325, #326: fbc: add support for wstrings used with __FB_EVAL__()
21+
- crt headers: minimal crt headers to compile fbc and build test-suite on freebsd-13.0-i386
22+
- darwin: Implemented objinfo for Darwin/OSX Mach-O .o files, so #inclib etc. work (TeeEmCee)
23+
- darwin: put objinfo in 'fbctinf, __DATA' section instead of '.fbctinf' (TeeEmCee)
24+
- fbc: add '-entry name' command line option to set program entry point (TeeEmCee)
25+
- added objinfo support for ELF files on freebsd
1726

1827
[fixed]
1928
- github #315: set parameters when calling SCREENCONTROL (was broken in fbc 1.08.0 due to new LONG/LONGINT SCREENCONTROL API's)
@@ -25,6 +34,8 @@ Version 1.09.0
2534
- github #324: fbc: When converting a wide character escape sequence to an internal format, the escaped value is incorrect. (Skyfish)
2635
- fbc: remove warning on function suffix in '-lang qb'
2736
- github #325, #326: fbc: constant folding ASC() on constant strings with embedded NUL characters - previously ASC returned 0 for anything past the first embedded NUL char, for example ASC(!"A\000B",3) incorrectly returned 0 and should return 66
37+
- rtlib: define fb_AtomicSetThreadFlags() even in the non-multithreaded version of run time library - it is needed by thread_core.c:threadproc() - unusual but not impossible to link the non-multithreaded rtlib and call thread functions
38+
- darwin: a variety of improvements to allow compiling and linking (TeeEmCee)
2839

2940

3041
Version 1.08.0

doc/fbc.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Enable full error location reporting
6363
\fB\-enullptr\fR
6464
Enable null-pointer checking
6565
.TP
66+
\fB\-entry\fR \fIname\fR
67+
Change the entry point of the program from main()
68+
.TP
6669
\fB\-ex\fR
6770
\fB-e\fR plus RESUME support
6871
.TP

inc/crt/freebsd/stdio.bi

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef __crt_freebsd_stdio_bi__
2+
#define __crt_freebsd_stdio_bi__
3+
4+
#define _IOFBF 0
5+
#define _IOLBF 1
6+
#define _IONBF 2
7+
#define BUFSIZ 1024
8+
#define FILENAME_MAX 1024
9+
#define FOPEN_MAX 20
10+
#define P_tmpdir "/tmp" 'Actual P_tmpdir on FreeBSD is "/tmp/"
11+
#define L_tmpnam 1024
12+
#define TMP_MAX 308915776
13+
14+
type FILE as _sFILE
15+
16+
extern stdin alias "__stdinp" as FILE ptr
17+
extern stdout alias "__stdoutp" as FILE ptr
18+
extern stderr alias "__stderrp" as FILE ptr
19+
20+
type fpos_t as longint 'Equal to __off_t
21+
22+
extern "c"
23+
declare function snprintf (byval s as zstring ptr, byval n as size_t, byval format as zstring ptr, ...) as long
24+
declare function vsnprintf (byval s as zstring ptr, byval n as size_t, byval format as zstring ptr, byval arg as va_list) as long
25+
declare function popen (byval as zstring ptr, byval as zstring ptr) as FILE ptr
26+
declare function pclose (byval as FILE ptr) as long
27+
declare function getw (byval as FILE ptr) as long
28+
declare function putw (byval as long, byval as FILE ptr) as long
29+
30+
end extern
31+
32+
#endif

inc/crt/freebsd/time.bi

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
''
2+
''
3+
'' time -- header translated with help of SWIG FB wrapper
4+
''
5+
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
6+
'' be included in other distributions without authorization.
7+
''
8+
''
9+
#ifndef __crt_linux_time_bi__
10+
#define __crt_linux_time_bi__
11+
12+
#include once "crt/long.bi"
13+
14+
'' begin_include "bits/time.bi"
15+
16+
#define CLOCKS_PER_SEC 1000000l
17+
18+
extern "C"
19+
declare function __sysconf (byval as long) as clong
20+
end extern
21+
22+
'' end_include "bits/time.bi"
23+
24+
type clock_t as __clock_t
25+
type time_t as __time_t
26+
27+
type timespec
28+
tv_sec as __time_t
29+
tv_nsec as clong
30+
end type
31+
32+
type tm
33+
tm_sec as long
34+
tm_min as long
35+
tm_hour as long
36+
tm_mday as long
37+
tm_mon as long
38+
tm_year as long
39+
tm_wday as long
40+
tm_yday as long
41+
tm_isdst as long
42+
__tm_gmtoff as clong
43+
__tm_zone as zstring ptr
44+
end type
45+
46+
extern "C"
47+
48+
declare function gmtime_r (byval __timer as time_t ptr, byval __tp as tm ptr) as tm ptr
49+
declare function localtime_r (byval __timer as time_t ptr, byval __tp as tm ptr) as tm ptr
50+
declare function asctime_r (byval __tp as tm ptr, byval __buf as zstring ptr) as zstring ptr
51+
declare function ctime_r (byval __timer as time_t ptr, byval __buf as zstring ptr) as zstring ptr
52+
53+
extern __tzname as zstring * 2
54+
extern __daylight as long
55+
extern __timezone as clong
56+
57+
declare function timegm (byval __tp as tm ptr) as time_t
58+
declare function timelocal (byval __tp as tm ptr) as time_t
59+
declare function dysize (byval __year as long) as long
60+
61+
end extern
62+
63+
#endif

inc/crt/freebsd/wchar.bi

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#include once "crt/stdio.bi"
4+
#include once "crt/stdarg.bi"
5+
#include once "crt/stddef.bi"
6+
#include once "crt/long.bi"
7+
#include once "crt/stdint.bi"
8+
#include once "crt/limits.bi"
9+
10+
extern "C"
11+
12+
type mbstate_t as __mbstate_t
13+
14+
#ifndef wchar_t
15+
type wchar_t as __wchar_t
16+
#endif
17+
18+
#ifndef wint_t
19+
type wint_t as __wint_t
20+
#endif
21+
22+
#ifndef WEOF
23+
const WEOF = cast(wint_t, -1)
24+
#endif
25+
26+
end extern

inc/crt/linux/wchar.bi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ end type
3131

3232
extern "C"
3333

34-
declare function wmemcpy (byval __s1 as wchar_t ptr, byval __s2 as wchar_t ptr, byval __n as size_t) as wchar_t ptr
3534
declare function __mbrlen (byval __s as zstring ptr, byval __n as size_t, byval __ps as mbstate_t ptr) as size_t
3635
declare function __wcstod_internal (byval __nptr as wchar_t ptr, byval __endptr as wchar_t ptr ptr, byval __group as long) as double
3736
declare function __wcstof_internal (byval __nptr as wchar_t ptr, byval __endptr as wchar_t ptr ptr, byval __group as long) as single

inc/crt/stddef.bi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ type ptrdiff_t as integer
2323
#endif
2424
#endif
2525

26+
#ifndef wchar_t
2627
#ifdef __FB_DOS__
2728
type wchar_t as ubyte
2829
#elseif defined( __FB_WIN32__ ) or defined( __FB_CYGWIN__ )
2930
type wchar_t as ushort
3031
#else
3132
type wchar_t as long
3233
#endif
34+
#endif
3335

34-
type wint_t as wchar_t
36+
#ifndef wint_t
37+
type wint_t as wchar_t
38+
#endif
3539

3640
#ifndef NULL
3741
#define NULL 0

inc/crt/stdio.bi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
#include once "crt/dos/stdio.bi"
2828
#elseif defined(__FB_LINUX__)
2929
#include once "crt/linux/stdio.bi"
30+
#elseif defined(__FB_FREEBSD__)
31+
#include once "crt/freebsd/stdio.bi"
32+
#elseif defined(__FB_UNIX__)
33+
'' Other Unices are likely to be BSD variants. stdio.bi is the most important
34+
'' crt header, so try to make FB work on other OSes.
35+
#print WARNING: Platform not supported; falling back to FreeBSD stdio.bi header
36+
#include once "crt/freebsd/stdio.bi"
37+
#else
38+
#error Unsupported platform
3039
#endif
3140

3241
extern "c"

inc/crt/stdlib.bi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#if defined(__FB_WIN32__)
1616
#include once "crt/win32/stdlib.bi"
17-
#elseif defined(__FB_LINUX__)
18-
#include once "crt/linux/stdlib.bi"
17+
#elseif defined(__FB_UNIX__)
18+
#include once "crt/unix/stdlib.bi"
1919
#endif
2020

2121
type div_t

inc/crt/sys/freebsd/types.bi

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
''
2+
''
3+
'' sys\types
4+
''
5+
''
6+
''
7+
''
8+
''
9+
#ifndef __crt_sys_freebsd_types_bi__
10+
#define __crt_sys_freebsd_types_bi__
11+
12+
type __clock_t as integer
13+
type __time_t as integer
14+
15+
union __mstate_t
16+
as ubyte __mbstate8(0 to 127)
17+
as ulongint _mbstateL
18+
end union
19+
20+
#endif

0 commit comments

Comments
 (0)