Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a3ab3e6
crt-headers: move inc/crt/linux/stdlib.bi to inc/crt/unix/stdlib.bi
jayrm Jul 17, 2021
dc958a8
crt-headers: fallback to inc/crt/unix/stdlib.bi when not stdlib.bi th…
jayrm Jul 17, 2021
3dd06b3
freebsd: add crt-headers for minimal time.bi and time types
jayrm Jul 17, 2021
d76190e
freebsd: add minimal inc/crt/freebsd/stdio.bi, wchar.bi, sys/freebsd/…
jayrm Jul 17, 2021
638de29
fbc-tests: update makefiles for freebsd
jayrm Jul 13, 2021
676fc18
fbc-tests: typo in tests/fbcunit/makefile
jayrm Jul 17, 2021
4363f1a
fbc-tests: update changelog.txt
jayrm Jul 17, 2021
b49af04
rtlib: enable fb_AtomicSetThreadFlags() in src/rtlib/thread_self.c
jayrm Jul 13, 2021
3b09425
darwin: Implement objinfo Mach-O parser
rversteegen Apr 23, 2016
ad060f2
fbc: add internal function fbTargetSupportsMachO() to check for Mach-…
jayrm Jul 17, 2021
44a193c
darwin: The fbctinf section needs to go in some segment; put it in __…
rversteegen Apr 13, 2016
8f07da0
changelog.txt: darwin: put objinfo in 'fbctinf, __DATA' section inste…
jayrm Jul 17, 2021
4f19f1b
fbc: Add -entry commandline option to override the name of the entry …
rversteegen Apr 13, 2016
4dc40b8
update changelog.txt and doc/fbc.1 for new '-entry name' command line…
jayrm Jul 17, 2021
94d8108
darwin/x86 backend: Fix constructor and destructor sections.
rversteegen May 9, 2016
f70f29a
darwin: default to -gen gcc
rversteegen Apr 23, 2016
42ca81d
darwin: Default to at&t instead of intel asm syntax on Darwin except …
rversteegen Apr 13, 2016
e9d9d67
darwin: pass -macosx_version_min=10.4 instead of 10.6.
rversteegen Apr 14, 2016
78435dc
darwin: Fix name mangling in cpudetect.s
rversteegen Apr 14, 2016
10696a9
darwin: prefix function names with underscores
rversteegen Apr 23, 2016
ee666f1
darwin: pass argument to tell ld the target architecture
rversteegen Apr 23, 2016
bfad325
darwin: 'as' expects temp labels to begin with L not .L
rversteegen Apr 23, 2016
364d254
update changelog.txt
jayrm Jul 18, 2021
13e22ae
gen gcc: allow compiling with GCC 4.5 and older, by avoiding -Wno-unu…
rversteegen May 10, 2016
162341a
update changelog.txt
jayrm Jul 18, 2021
a4debb1
darwin/rtlib: implement FRE and add a bunch of missing stub functions
rversteegen Oct 22, 2016
53691bb
darwin: dylibload should check for .dylib files too
rversteegen Apr 5, 2017
0d7d036
When using -gen gcc, ask gcc which as and ld to use. This fixes FreeBSD.
rversteegen Jun 22, 2017
183e774
update changelog.txt
jayrm Jul 18, 2021
f14bf05
fbc-tests: fix freebsd test for tests/optimizations/inline-ops.bas
jayrm Jul 13, 2021
3d1ecb9
freebsd: added objinfo support for ELF files on freebsd i386
jayrm Jul 17, 2021
7b91e93
rtlib: freebsd: minimum thread stacksize 8192 KiB
jayrm Jul 18, 2021
8835777
fbc-tests: dissallow cva_list returned by value on freebsd 64-bit
jayrm Jul 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ Version 1.09.0
- crt headers: add const qualifiers in crt/stdio.bi, crt/sys/stat.bi, crt/wchar.bi
- crt headers: add const qualifiers in crt/sys/win32/stat.bi, crt/win32/stdio.bi
- github #325, #326: fbc: internal changes for string processing functions
- fbc-tests: xargs on freebsd does not support the '-a filename' option, use 'cat filename | xargs' instead
- fbc: gen gcc: allow compiling with GCC 4.5 and older, by avoiding -Wno-unused-but-set-variable (TeeEmCee)
- fbc: internal function fbcQueryGcc() to ask gcc for the correct as & ld to use (TeeEmCee)
- rtlib: freebsd: minimum thread stacksize 8192 KiB

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

[fixed]
- github #315: set parameters when calling SCREENCONTROL (was broken in fbc 1.08.0 due to new LONG/LONGINT SCREENCONTROL API's)
Expand All @@ -25,6 +34,8 @@ Version 1.09.0
- github #324: fbc: When converting a wide character escape sequence to an internal format, the escaped value is incorrect. (Skyfish)
- fbc: remove warning on function suffix in '-lang qb'
- 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
- 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
- darwin: a variety of improvements to allow compiling and linking (TeeEmCee)


Version 1.08.0
Expand Down
3 changes: 3 additions & 0 deletions doc/fbc.1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Enable full error location reporting
\fB\-enullptr\fR
Enable null-pointer checking
.TP
\fB\-entry\fR \fIname\fR
Change the entry point of the program from main()
.TP
\fB\-ex\fR
\fB-e\fR plus RESUME support
.TP
Expand Down
32 changes: 32 additions & 0 deletions inc/crt/freebsd/stdio.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef __crt_freebsd_stdio_bi__
#define __crt_freebsd_stdio_bi__

#define _IOFBF 0
#define _IOLBF 1
#define _IONBF 2
#define BUFSIZ 1024
#define FILENAME_MAX 1024
#define FOPEN_MAX 20
#define P_tmpdir "/tmp" 'Actual P_tmpdir on FreeBSD is "/tmp/"
#define L_tmpnam 1024
#define TMP_MAX 308915776

type FILE as _sFILE

extern stdin alias "__stdinp" as FILE ptr
extern stdout alias "__stdoutp" as FILE ptr
extern stderr alias "__stderrp" as FILE ptr

type fpos_t as longint 'Equal to __off_t

extern "c"
declare function snprintf (byval s as zstring ptr, byval n as size_t, byval format as zstring ptr, ...) as long
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
declare function popen (byval as zstring ptr, byval as zstring ptr) as FILE ptr
declare function pclose (byval as FILE ptr) as long
declare function getw (byval as FILE ptr) as long
declare function putw (byval as long, byval as FILE ptr) as long

end extern

#endif
63 changes: 63 additions & 0 deletions inc/crt/freebsd/time.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
''
''
'' time -- header translated with help of SWIG FB wrapper
''
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
'' be included in other distributions without authorization.
''
''
#ifndef __crt_linux_time_bi__
#define __crt_linux_time_bi__

#include once "crt/long.bi"

'' begin_include "bits/time.bi"

#define CLOCKS_PER_SEC 1000000l

extern "C"
declare function __sysconf (byval as long) as clong
end extern

'' end_include "bits/time.bi"

type clock_t as __clock_t
type time_t as __time_t

type timespec
tv_sec as __time_t
tv_nsec as clong
end type

type tm
tm_sec as long
tm_min as long
tm_hour as long
tm_mday as long
tm_mon as long
tm_year as long
tm_wday as long
tm_yday as long
tm_isdst as long
__tm_gmtoff as clong
__tm_zone as zstring ptr
end type

extern "C"

declare function gmtime_r (byval __timer as time_t ptr, byval __tp as tm ptr) as tm ptr
declare function localtime_r (byval __timer as time_t ptr, byval __tp as tm ptr) as tm ptr
declare function asctime_r (byval __tp as tm ptr, byval __buf as zstring ptr) as zstring ptr
declare function ctime_r (byval __timer as time_t ptr, byval __buf as zstring ptr) as zstring ptr

extern __tzname as zstring * 2
extern __daylight as long
extern __timezone as clong

declare function timegm (byval __tp as tm ptr) as time_t
declare function timelocal (byval __tp as tm ptr) as time_t
declare function dysize (byval __year as long) as long

end extern

#endif
26 changes: 26 additions & 0 deletions inc/crt/freebsd/wchar.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include once "crt/stdio.bi"
#include once "crt/stdarg.bi"
#include once "crt/stddef.bi"
#include once "crt/long.bi"
#include once "crt/stdint.bi"
#include once "crt/limits.bi"

extern "C"

type mbstate_t as __mbstate_t

#ifndef wchar_t
type wchar_t as __wchar_t
#endif

#ifndef wint_t
type wint_t as __wint_t
#endif

#ifndef WEOF
const WEOF = cast(wint_t, -1)
#endif

end extern
1 change: 0 additions & 1 deletion inc/crt/linux/wchar.bi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ end type

extern "C"

declare function wmemcpy (byval __s1 as wchar_t ptr, byval __s2 as wchar_t ptr, byval __n as size_t) as wchar_t ptr
declare function __mbrlen (byval __s as zstring ptr, byval __n as size_t, byval __ps as mbstate_t ptr) as size_t
declare function __wcstod_internal (byval __nptr as wchar_t ptr, byval __endptr as wchar_t ptr ptr, byval __group as long) as double
declare function __wcstof_internal (byval __nptr as wchar_t ptr, byval __endptr as wchar_t ptr ptr, byval __group as long) as single
Expand Down
6 changes: 5 additions & 1 deletion inc/crt/stddef.bi
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ type ptrdiff_t as integer
#endif
#endif

#ifndef wchar_t
#ifdef __FB_DOS__
type wchar_t as ubyte
#elseif defined( __FB_WIN32__ ) or defined( __FB_CYGWIN__ )
type wchar_t as ushort
#else
type wchar_t as long
#endif
#endif

type wint_t as wchar_t
#ifndef wint_t
type wint_t as wchar_t
#endif

#ifndef NULL
#define NULL 0
Expand Down
9 changes: 9 additions & 0 deletions inc/crt/stdio.bi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
#include once "crt/dos/stdio.bi"
#elseif defined(__FB_LINUX__)
#include once "crt/linux/stdio.bi"
#elseif defined(__FB_FREEBSD__)
#include once "crt/freebsd/stdio.bi"
#elseif defined(__FB_UNIX__)
'' Other Unices are likely to be BSD variants. stdio.bi is the most important
'' crt header, so try to make FB work on other OSes.
#print WARNING: Platform not supported; falling back to FreeBSD stdio.bi header
#include once "crt/freebsd/stdio.bi"
#else
#error Unsupported platform
#endif

extern "c"
Expand Down
4 changes: 2 additions & 2 deletions inc/crt/stdlib.bi
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#if defined(__FB_WIN32__)
#include once "crt/win32/stdlib.bi"
#elseif defined(__FB_LINUX__)
#include once "crt/linux/stdlib.bi"
#elseif defined(__FB_UNIX__)
#include once "crt/unix/stdlib.bi"
#endif

type div_t
Expand Down
20 changes: 20 additions & 0 deletions inc/crt/sys/freebsd/types.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
''
''
'' sys\types
''
''
''
''
''
#ifndef __crt_sys_freebsd_types_bi__
#define __crt_sys_freebsd_types_bi__

type __clock_t as integer
type __time_t as integer

union __mstate_t
as ubyte __mbstate8(0 to 127)
as ulongint _mbstateL
end union

#endif
2 changes: 2 additions & 0 deletions inc/crt/sys/types.bi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include once "crt/sys/dos/types.bi"
#elseif defined(__FB_LINUX__)
#include once "crt/sys/linux/types.bi"
#elseif defined(__FB_FREEBSD__)
#include once "crt/sys/freebsd/types.bi"
#else
#error Platform unsupported
#endif
Expand Down
2 changes: 2 additions & 0 deletions inc/crt/time.bi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include once "crt/dos/time.bi"
#elseif defined(__FB_LINUX__)
#include once "crt/linux/time.bi"
#elseif defined(__FB_FREEBSD__)
#include once "crt/freebsd/time.bi"
#endif

extern "c"
Expand Down
6 changes: 3 additions & 3 deletions inc/crt/linux/stdlib.bi → inc/crt/unix/stdlib.bi
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
'' be included in other distributions without authorization.
''
''
#ifndef __crt_linux_stdlib_bi__
#define __crt_linux_stdlib_bi__
#ifndef __crt_unix_stdlib_bi__
#define __crt_unix_stdlib_bi__

extern "c"
declare function mkstemp (byval template_ as zstring ptr) as long
end extern

#endif '' __crt_linux_stdlib_bi__
#endif '' __crt_unix_stdlib_bi__
3 changes: 3 additions & 0 deletions inc/crt/wchar.bi
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include once "crt/win32/wchar.bi"
#elseif defined(__FB_LINUX__)
#include once "crt/linux/wchar.bi"
#elseif defined(__FB_FREEBSD__)
#include once "crt/freebsd/wchar.bi"
#elseif defined(__FB_DOS__)
#include once "crt/dos/wchar.bi"
#endif
Expand All @@ -38,6 +40,7 @@ declare function wmemset (byval s as wchar_t ptr, byval c as wchar_t, byval n as
declare function wmemchr (byval s as const wchar_t ptr, byval c as wchar_t, byval n as size_t) as wchar_t ptr
declare function wmemcmp (byval s1 as const wchar_t ptr, byval s2 as const wchar_t ptr, byval n as size_t) as integer
declare function wmemmove (byval s1 as wchar_t ptr, byval s2 as const wchar_t ptr, byval n as size_t) as wchar_t ptr
declare function wmemcpy(byval as wchar_t ptr, byval as const wchar_t ptr, byval as uinteger) as wstring ptr
end extern

#endif
45 changes: 31 additions & 14 deletions src/compiler/emit_x86.bas
Original file line number Diff line number Diff line change
Expand Up @@ -7189,7 +7189,9 @@ private function _getSectionString _

ostr = NEWLINE

'' Omit the .section directive on Darwin
'' Omit the .section directive on Darwin.
'' as accepts .text, .const, and many others as shorthands, while .section has a different syntax:
'' .section segment , section [[[ , type ] , attribute] , sizeof_stub]
if (fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_DARWIN) then
ostr += ".section "
end if
Expand Down Expand Up @@ -7221,27 +7223,42 @@ private function _getSectionString _
ostr += "text"

case IR_SECTION_DIRECTIVE
'' TODO: there is no .drectve on Darwin
ostr += "drectve"

case IR_SECTION_INFO
ostr += FB_INFOSEC_NAME
if (fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DARWIN) then
ostr += "section __DATA," + FB_INFOSEC_NAME
else
ostr += FB_INFOSEC_NAME
end if

case IR_SECTION_CONSTRUCTOR
ostr += "ctors"
if( priority > 0 ) then
ostr += "." + right( "00000" + str( 65535 - priority ), 5 )
end if
if( env.clopt.target = FB_COMPTARGET_LINUX ) then
ostr += ", " + QUOTE + "aw" + QUOTE + ", @progbits"
if (fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DARWIN) then
'' Darwin assembler does not support ctor priorities
ostr += "constructor"
else
ostr += "ctors"
if( priority > 0 ) then
ostr += "." + right( "00000" + str( 65535 - priority ), 5 )
end if
if( env.clopt.target = FB_COMPTARGET_LINUX ) then
ostr += ", " + QUOTE + "aw" + QUOTE + ", @progbits"
end if
end if

case IR_SECTION_DESTRUCTOR
ostr += "dtors"
if( priority > 0 ) then
ostr += "." + right( "00000" + str( 65535 - priority ), 5 )
end if
if( env.clopt.target = FB_COMPTARGET_LINUX ) then
ostr += ", " + QUOTE + "aw" + QUOTE + ", @progbits"
if (fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_DARWIN) then
'' Darwin assembler does not support dtor priorities
ostr += "destructor"
else
ostr += "dtors"
if( priority > 0 ) then
ostr += "." + right( "00000" + str( 65535 - priority ), 5 )
end if
if( env.clopt.target = FB_COMPTARGET_LINUX ) then
ostr += ", " + QUOTE + "aw" + QUOTE + ", @progbits"
end if
end if

end select
Expand Down
Loading