1
/* ==== machdep.c ============================================================
2
* Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
4
* Description : Machine dependent functions for SunOS-4.1.3 on sparc
7
* -Started coding this file.
10
* -update for fat sigset_t in NetBSD 1.3H
14
static const char rcsid[] = "$Id$";
22
/* ==========================================================================
23
* machdep_save_state()
25
int machdep_save_state(void)
27
/* Save register windows onto stackframe */
30
return(setjmp(pthread_run->machdep_data.machdep_state));
33
/* ==========================================================================
34
* machdep_restore_state()
36
void machdep_restore_state(void)
38
longjmp(pthread_run->machdep_data.machdep_state, 1);
40
/* ==========================================================================
41
* machdep_save_float_state()
43
void machdep_save_float_state(struct pthread * pthread)
48
/* ==========================================================================
49
* machdep_restore_float_state()
51
void machdep_restore_float_state(void)
56
/* ==========================================================================
57
* machdep_set_thread_timer()
59
void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
61
if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
66
/* ==========================================================================
67
* machdep_unset_thread_timer()
69
void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
71
struct itimerval zeroval = { { 0, 0 }, { 0, 0} };
73
if (setitimer(ITIMER_VIRTUAL, &zeroval, NULL)) {
78
/* ==========================================================================
79
* machdep_pthread_cleanup()
81
void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
83
return(machdep_pthread->machdep_stack);
86
/* ==========================================================================
87
* machdep_pthread_start()
89
void machdep_pthread_start(void)
91
context_switch_done();
92
pthread_sched_resume ();
94
/* Run current threads start routine with argument */
95
pthread_exit(pthread_run->machdep_data.start_routine
96
(pthread_run->machdep_data.start_argument));
98
/* should never reach here */
102
/* ==========================================================================
103
* __machdep_stack_free()
105
void __machdep_stack_free(void * stack)
110
/* ==========================================================================
111
* __machdep_stack_alloc()
113
void * __machdep_stack_alloc(size_t size)
117
return(malloc(size));
120
/* ==========================================================================
121
* __machdep_pthread_create()
123
void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
124
void *(* start_routine)(), void *start_argument,
125
long stack_size, long nsec, long flags)
127
machdep_pthread->start_routine = start_routine;
128
machdep_pthread->start_argument = start_argument;
130
machdep_pthread->machdep_timer.it_value.tv_sec = 0;
131
machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
132
machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
133
machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
135
/* Save register windows onto stackframe */
138
setjmp(machdep_pthread->machdep_state);
140
* Set up new stact frame so that it looks like it
141
* returned from a longjmp() to the beginning of
142
* machdep_pthread_start().
144
machdep_pthread->machdep_state[3] = (int)machdep_pthread_start;
145
machdep_pthread->machdep_state[4] = (int)machdep_pthread_start;
147
/* Sparc stack starts high and builds down. */
148
machdep_pthread->machdep_state[2] =
149
(int)machdep_pthread->machdep_stack + stack_size - 1024;
150
machdep_pthread->machdep_state[2] &= ~7;
154
#if defined(HAVE_SYSCALL_GETDENTS)
155
/* ==========================================================================
156
* machdep_sys_getdirentries()
158
* Always use getdents in place of getdirentries if possible --proven
160
int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
162
return(machdep_sys_getdents(fd, buf, len));
166
/* ==========================================================================
167
* machdep_sys_wait3()
169
machdep_sys_wait3(int * b, int c, int * d)
171
return(machdep_sys_wait4(0, b, c, d));
174
/* ==========================================================================
175
* machdep_sys_waitpid()
177
machdep_sys_waitpid(int pid, int * statusp, int options)
183
return machdep_sys_wait4 (pid, statusp, options, NULL);
186
#if !defined(HAVE_SYSCALL_SIGPROCMASK)
188
/* ==========================================================================
189
* machdep_sys_sigprocmask()
190
* This isn't a real implementation; we can make the assumption that the
191
* pthreads library is not using oset, and that it is always blocking or
192
* unblocking all signals at once.
194
int machdep_sys_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
212
/* ==========================================================================
215
* Temporary until I do machdep_sys_sigaction()
217
int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact)
219
return(sigvec(sig, (struct sigvec *)act, (struct sigvec *)oldact));
224
#if !defined(HAVE_SYSCALL_GETDTABLESIZE)
225
/* ==========================================================================
226
* machdep_sys_getdtablesize()
228
machdep_sys_getdtablesize()
230
return(sysconf(_SC_OPEN_MAX));