Skip to content

Commit

Permalink
phobos 1.00
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Sep 10, 2007
1 parent 7a177fc commit 1a1d0c4
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 95 deletions.
47 changes: 47 additions & 0 deletions internal/gc/gc.d
Expand Up @@ -228,6 +228,14 @@ ulong _d_newarrayi(size_t length, size_t size, ...)
debug(PRINTF) printf(" p = %p\n", p);
if (size == 1)
memset(p, *cast(ubyte*)q, length);
else if (size == int.sizeof)
{
int init = *cast(int*)q;
for (uint u = 0; u < length; u++)
{
(cast(int*)p)[u] = init;
}
}
else
{
for (uint u = 0; u < length; u++)
Expand All @@ -241,6 +249,45 @@ ulong _d_newarrayi(size_t length, size_t size, ...)
return result;
}

ulong _d_newarrayii(size_t length, size_t size, size_t isize ...)
{
void *p;
ulong result;

//debug(PRINTF) printf("_d_newarrayii(length = %d, size = %d, isize = %d)\n", length, size, isize);
if (length == 0 || size == 0)
result = 0;
else
{
//void* q = cast(void*)(&size + 1); // pointer to initializer
va_list q;
va_start!(size_t)(q, isize); // q is pointer to ... initializer
size *= length;
p = _gc.malloc(size * isize + 1);
debug(PRINTF) printf(" p = %p\n", p);
if (isize == 1)
memset(p, *cast(ubyte*)q, size);
else if (isize == int.sizeof)
{
int init = *cast(int*)q;
for (uint u = 0; u < size; u++)
{
(cast(int*)p)[u] = init;
}
}
else
{
for (uint u = 0; u < size; u++)
{
memcpy(p + u * isize, q, isize);
}
}
va_end(q);
result = cast(ulong)length + (cast(ulong)cast(uint)p << 32);
}
return result;
}

ulong _d_newm(size_t size, int ndims, ...)
{
ulong result;
Expand Down
2 changes: 1 addition & 1 deletion linux.mak
Expand Up @@ -141,7 +141,7 @@ SRC_STD_C_WIN= std/c/windows/windows.d std/c/windows/com.d \
std/c/windows/winsock.d std/c/windows/stat.d

SRC_STD_C_LINUX= std/c/linux/linux.d std/c/linux/linuxextern.d \
std/c/linux/socket.d
std/c/linux/socket.d std/c/linux/pthread.d

SRC_ETC= etc/gamma.d

Expand Down
92 changes: 1 addition & 91 deletions std/c/linux/linux.d
Expand Up @@ -9,6 +9,7 @@
module std.c.linux.linux;

public import std.c.linux.linuxextern;
public import std.c.linux.pthread;

alias int pid_t;
alias int off_t;
Expand Down Expand Up @@ -417,97 +418,6 @@ extern (C)
int sigsuspend(sigset_t*);
}

extern (C)
{
/* pthread declarations taken from pthread headers and
http://svn.dsource.org/projects/bindings/trunk/pthreads.d
*/

/* from bits/types.h
*/

typedef int __time_t;

/* from time.h
*/

struct timespec
{
__time_t tv_sec; /* seconds */
int tv_nsec; /* nanosecs. */
}

/* from bits/pthreadtypes.h
*/

struct _pthread_descr_struct
{
/* Not defined in the headers ???
Just needed here to typedef
the _pthread_descr pointer
*/
}

typedef _pthread_descr_struct* _pthread_descr;

struct _pthread_fastlock
{
int __status;
int __spinlock;
}

typedef long __pthread_cond_align_t;

struct pthread_cond_t
{
_pthread_fastlock __c_lock;
_pthread_descr __c_waiting;
char[48
- _pthread_fastlock.sizeof
- _pthread_descr.sizeof
- __pthread_cond_align_t.sizeof
] __padding;
__pthread_cond_align_t __align;
}

struct pthread_condattr_t
{
int __dummy;
}

struct pthread_mutex_t
{
int __m_reserved;
int __m_count;
_pthread_descr __m_owner;
int __m_kind;
_pthread_fastlock __m_lock;
}

struct pthread_mutexattr_t
{
int __mutexkind;
}

/* from pthread.h
*/

int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
int pthread_mutex_destroy(pthread_mutex_t*);
int pthread_mutex_trylock(pthread_mutex_t*);
int pthread_mutex_lock(pthread_mutex_t*);
int pthread_mutex_unlock(pthread_mutex_t*);

int pthread_mutexattr_init(pthread_mutexattr_t*);
int pthread_mutexattr_destroy(pthread_mutexattr_t*);

int pthread_cond_init(pthread_cond_t*, pthread_condattr_t*);
int pthread_cond_destroy(pthread_cond_t*);
int pthread_cond_signal(pthread_cond_t*);
int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, timespec*);
}

extern (C)
{
/* from semaphore.h
Expand Down

0 comments on commit 1a1d0c4

Please sign in to comment.