mirror of
https://github.com/dlang/phobos.git
synced 2025-05-11 23:05:34 +03:00
more OSX fixes
This commit is contained in:
parent
ee2e233485
commit
1fe5f7859f
5 changed files with 127 additions and 15 deletions
13
osx.mak
13
osx.mak
|
@ -203,10 +203,11 @@ ALLSRCS = $(SRC) $(SRC_STD) $(SRC_STD_C) $(SRC_TI) $(SRC_INT) $(SRC_STD_WIN) \
|
|||
$(SRC_ZLIB) $(SRC_GC)
|
||||
|
||||
|
||||
$(LIB) : $(OBJS) $(GC_OBJS) $(ZLIB_OBJS) osx.mak
|
||||
rm -f $(LIB)
|
||||
ar -r $@ $(OBJS) $(ZLIB_OBJS) $(GC_OBJS)
|
||||
# $(DMD) -lib -of$(LIB) $(DFLAGS) $(SRCS) $(OBJS) $(ZLIB_OBJS) $(GC_OBJS)
|
||||
$(LIB) : $(OBJS) $(GC_OBJS) $(ZLIB_OBJS) $(SRCS) osx.mak
|
||||
# rm -f $(LIB)
|
||||
# ar -r $@ $(OBJS) $(ZLIB_OBJS) $(GC_OBJS)
|
||||
$(DMD) -lib -of$(LIB) $(DFLAGS) $(SRCS) $(OBJS) $(ZLIB_OBJS) $(GC_OBJS)
|
||||
# $(DMD) -lib -of$(LIB) $(OBJS) $(ZLIB_OBJS) $(GC_OBJS)
|
||||
|
||||
unittest :
|
||||
$(DMD) $(DFLAGS) -unittest -version=Unittest unittest.d $(SRCS) $(LIB)
|
||||
|
@ -223,13 +224,13 @@ $(GC_OBJS):
|
|||
# cd internal/gc
|
||||
# make -f linux.mak dmgc.a
|
||||
# cd ../..
|
||||
make -C ./internal/gc -f linux.mak
|
||||
make DMD=$(DMD) -C ./internal/gc -f osx.mak
|
||||
|
||||
$(ZLIB_OBJS):
|
||||
# cd etc/c/zlib
|
||||
# make -f linux.mak
|
||||
# cd ../../..
|
||||
make -C ./etc/c/zlib -f linux.mak
|
||||
make -C ./etc/c/zlib -f osx.mak
|
||||
|
||||
###
|
||||
|
||||
|
|
|
@ -222,6 +222,8 @@ enum
|
|||
|
||||
// Memory mapping sharing types
|
||||
|
||||
version (linux)
|
||||
{
|
||||
enum
|
||||
{ MAP_SHARED = 1,
|
||||
MAP_PRIVATE = 2,
|
||||
|
@ -246,6 +248,33 @@ enum
|
|||
MS_INVALIDATE = 2,
|
||||
MS_SYNC = 4,
|
||||
}
|
||||
}
|
||||
|
||||
version (OSX)
|
||||
{
|
||||
enum
|
||||
{ MAP_SHARED = 1,
|
||||
MAP_PRIVATE = 2,
|
||||
MAP_FIXED = 0x10,
|
||||
MAP_FILE = 0,
|
||||
MAP_ANON = 0x1000,
|
||||
MAP_NORESERVE = 0x40,
|
||||
|
||||
MAP_RENAME = 0x20,
|
||||
MAP_RESERVED0080 = 0x80,
|
||||
MAP_NOEXTEND = 0x100,
|
||||
MAP_HASSEMAPHORE = 0x200,
|
||||
MAP_NOCACHE = 0x400,
|
||||
}
|
||||
|
||||
// Values for msync()
|
||||
|
||||
enum
|
||||
{ MS_ASYNC = 1,
|
||||
MS_INVALIDATE = 2,
|
||||
MS_SYNC = 0x10,
|
||||
}
|
||||
}
|
||||
|
||||
// Values for mlockall()
|
||||
|
||||
|
|
|
@ -54,6 +54,22 @@ version (OSX)
|
|||
}
|
||||
}
|
||||
|
||||
version (FreeBSD)
|
||||
{
|
||||
const int EOF = -1;
|
||||
const int BUFSIZ = 1024;
|
||||
const int FOPEN_MAX = 20;
|
||||
const int FILENAME_MAX = 1024;
|
||||
const int TMP_MAX = 308915776;
|
||||
const int L_tmpnam = 1024;
|
||||
|
||||
struct __sbuf
|
||||
{
|
||||
char* _base;
|
||||
int _size;
|
||||
}
|
||||
}
|
||||
|
||||
enum { SEEK_SET, SEEK_CUR, SEEK_END }
|
||||
|
||||
struct _iobuf
|
||||
|
@ -116,6 +132,29 @@ struct _iobuf
|
|||
int _blksize;
|
||||
fpos_t _offset;
|
||||
}
|
||||
version (FreeBSD)
|
||||
{
|
||||
char* _p;
|
||||
int _r;
|
||||
int _w;
|
||||
short _flags;
|
||||
short _file;
|
||||
__sbuf _bf;
|
||||
int _lbfsize;
|
||||
void* _cookie;
|
||||
int function(void*) _close;
|
||||
int function(void*, char*, int) _read;
|
||||
fpos_t function(void*, fpos_t, int) _seek;
|
||||
int function(void*, char*, int) _write;
|
||||
__sbuf _ub;
|
||||
void* _extra;
|
||||
int _ur;
|
||||
char[3] _ubuf;
|
||||
char[1] _nbuf;
|
||||
__sbuf _lb;
|
||||
int _blksize;
|
||||
fpos_t _offset;
|
||||
}
|
||||
}
|
||||
|
||||
alias _iobuf FILE; ///
|
||||
|
@ -218,6 +257,19 @@ version (OSX)
|
|||
alias __stderrp stderr;
|
||||
}
|
||||
|
||||
version (FreeBSD)
|
||||
{
|
||||
alias long fpos_t;
|
||||
|
||||
extern FILE *__stdinp;
|
||||
extern FILE *__stdoutp;
|
||||
extern FILE *__stderrp;
|
||||
|
||||
alias __stdinp stdin;
|
||||
alias __stdoutp stdout;
|
||||
alias __stderrp stderr;
|
||||
}
|
||||
|
||||
|
||||
char * tmpnam(char *); ///
|
||||
FILE * fopen(char *,char *); ///
|
||||
|
|
|
@ -305,7 +305,8 @@ class MmFile
|
|||
else
|
||||
{
|
||||
fd = -1;
|
||||
flags |= MAP_ANONYMOUS;
|
||||
version (linux) flags |= MAP_ANONYMOUS;
|
||||
version (OSX) flags |= MAP_ANON;
|
||||
}
|
||||
this.size = size;
|
||||
size_t initial_map = (window && 2*window<size)? 2*window : cast(size_t)size;
|
||||
|
|
|
@ -61,9 +61,10 @@ class ModuleCtorError : Exception
|
|||
|
||||
// Win32: this gets initialized by minit.asm
|
||||
// linux: this gets initialized in _moduleCtor()
|
||||
// OSX: this gets initialized in _moduleCtor()
|
||||
extern (C) ModuleInfo[] _moduleinfo_array;
|
||||
|
||||
version (Posix)
|
||||
version (linux)
|
||||
{
|
||||
// This linked list is created by a compiler generated function inserted
|
||||
// into the .ctor list by the compiler.
|
||||
|
@ -76,6 +77,15 @@ version (Posix)
|
|||
extern (C) ModuleReference *_Dmodule_ref; // start of linked list
|
||||
}
|
||||
|
||||
version (OSX)
|
||||
{
|
||||
extern (C)
|
||||
{
|
||||
extern void* _minfo_beg;
|
||||
extern void* _minfo_end;
|
||||
}
|
||||
}
|
||||
|
||||
ModuleInfo[] _moduleinfo_dtors;
|
||||
uint _moduleinfo_dtors_i;
|
||||
|
||||
|
@ -89,7 +99,8 @@ extern (C) int _fatexit(void *);
|
|||
extern (C) void _moduleCtor()
|
||||
{
|
||||
debug printf("_moduleCtor()\n");
|
||||
version (Posix)
|
||||
|
||||
version (linux)
|
||||
{
|
||||
int len = 0;
|
||||
ModuleReference *mr;
|
||||
|
@ -104,6 +115,24 @@ extern (C) void _moduleCtor()
|
|||
}
|
||||
}
|
||||
|
||||
version (OSX)
|
||||
{ /* The ModuleInfo references are stored in the special segment
|
||||
* __minfodata, which is bracketed by the segments __minfo_beg
|
||||
* and __minfo_end. The variables _minfo_beg and _minfo_end
|
||||
* are of zero size and are in the two bracketing segments,
|
||||
* respectively.
|
||||
*/
|
||||
size_t length = cast(ModuleInfo*)&_minfo_end - cast(ModuleInfo*)&_minfo_beg;
|
||||
_moduleinfo_array = (cast(ModuleInfo*)&_minfo_beg)[0 .. length];
|
||||
debug printf("moduleinfo: ptr = %p, length = %d\n", _moduleinfo_array.ptr, _moduleinfo_array.length);
|
||||
|
||||
debug foreach (m; _moduleinfo_array)
|
||||
{
|
||||
//printf("\t%p\n", m);
|
||||
printf("\t%.*s\n", m.name);
|
||||
}
|
||||
}
|
||||
|
||||
version (Win32)
|
||||
{
|
||||
// Ensure module destructors also get called on program termination
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue