ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/sysdeps.h
(Generate patch)

Comparing BasiliskII/src/Unix/sysdeps.h (file contents):
Revision 1.21 by cebix, 2002-01-15T14:58:37Z vs.
Revision 1.34 by gbeauche, 2008-01-01T09:40:33Z

# Line 1 | Line 1
1   /*
2   *  sysdeps.h - System dependent definitions for Unix
3   *
4 < *  Basilisk II (C) 1997-2002 Christian Bauer
4 > *  Basilisk II (C) 1997-2008 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 43 | Line 43
43   #include <stdlib.h>
44   #include <string.h>
45  
46 + #ifdef HAVE_PTHREADS
47 + # include <pthread.h>
48 + #endif
49 +
50   #ifdef HAVE_FCNTL_H
51   # include <fcntl.h>
52   #endif
# Line 94 | Line 98
98  
99   #endif
100  
101 < /* Direct Addressing requires Video on SEGV signals */
102 < #if DIRECT_ADDRESSING && !ENABLE_VOSF
101 > /* Direct Addressing requires Video on SEGV signals in plain X11 mode */
102 > #if DIRECT_ADDRESSING && (!ENABLE_VOSF && !USE_SDL_VIDEO)
103   # undef  ENABLE_VOSF
104   # define ENABLE_VOSF 1
105   #endif
# Line 106 | Line 110
110   /* BSD socket API supported */
111   #define SUPPORTS_UDP_TUNNEL 1
112  
113 + /* Use the CPU emulator to check for periodic tasks? */
114 + #ifdef HAVE_PTHREADS
115 + #define USE_PTHREADS_SERVICES
116 + #endif
117 + #if EMULATED_68K
118 + #if defined(__NetBSD__)
119 + #define USE_CPU_EMUL_SERVICES
120 + #endif
121 + #endif
122 + #ifdef USE_CPU_EMUL_SERVICES
123 + #undef USE_PTHREADS_SERVICES
124 + #endif
125 +
126  
127   /* Data types */
128   typedef unsigned char uint8;
# Line 151 | Line 168 | typedef int64 intptr;
168   #error "Unsupported size of pointer"
169   #endif
170  
171 + #ifndef HAVE_LOFF_T
172 + typedef off_t loff_t;
173 + #endif
174 + #ifndef HAVE_CADDR_T
175 + typedef char * caddr_t;
176 + #endif
177 +
178   /* Time data type for Time Manager emulation */
179   #ifdef HAVE_CLOCK_GETTIME
180   typedef struct timespec tm_time_t;
# Line 158 | Line 182 | typedef struct timespec tm_time_t;
182   typedef struct timeval tm_time_t;
183   #endif
184  
185 + /* Define codes for all the float formats that we know of.
186 + * Though we only handle IEEE format.  */
187 + #define UNKNOWN_FLOAT_FORMAT 0
188 + #define IEEE_FLOAT_FORMAT 1
189 + #define VAX_FLOAT_FORMAT 2
190 + #define IBM_FLOAT_FORMAT 3
191 + #define C4X_FLOAT_FORMAT 4
192 +
193   /* UAE CPU data types */
194   #define uae_s8 int8
195   #define uae_u8 uint8
# Line 170 | Line 202 | typedef struct timeval tm_time_t;
202   typedef uae_u32 uaecptr;
203  
204   /* Alignment restrictions */
205 < #if defined(__i386__) || defined(__powerpc__) || defined(__m68k__)
205 > #if defined(__i386__) || defined(__powerpc__) || defined(__m68k__) || defined(__x86_64__)
206   # define CPU_CAN_ACCESS_UNALIGNED
207   #endif
208  
# Line 178 | Line 210 | typedef uae_u32 uaecptr;
210   extern uint64 GetTicks_usec(void);
211   extern void Delay_usec(uint32 usec);
212  
213 + /* Spinlocks */
214 + #ifdef __GNUC__
215 +
216 + #if defined(__powerpc__) || defined(__ppc__)
217 + #define HAVE_TEST_AND_SET 1
218 + static inline int testandset(volatile int *p)
219 + {
220 +        int ret;
221 +        __asm__ __volatile__("0:    lwarx       %0,0,%1\n"
222 +                                                 "      xor.    %0,%3,%0\n"
223 +                                                 "      bne             1f\n"
224 +                                                 "      stwcx.  %2,0,%1\n"
225 +                                                 "      bne-    0b\n"
226 +                                                 "1:    "
227 +                                                 : "=&r" (ret)
228 +                                                 : "r" (p), "r" (1), "r" (0)
229 +                                                 : "cr0", "memory");
230 +        return ret;
231 + }
232 + #endif
233 +
234 + /* FIXME: SheepShaver occasionnally hangs with those locks */
235 + #if 0 && (defined(__i386__) || defined(__x86_64__))
236 + #define HAVE_TEST_AND_SET 1
237 + static inline int testandset(volatile int *p)
238 + {
239 +        long int ret;
240 +        /* Note: the "xchg" instruction does not need a "lock" prefix */
241 +        __asm__ __volatile__("xchgl %k0, %1"
242 +                                                 : "=r" (ret), "=m" (*p)
243 +                                                 : "0" (1), "m" (*p)
244 +                                                 : "memory");
245 +        return ret;
246 + }
247 + #endif
248 +
249 + #ifdef __s390__
250 + #define HAVE_TEST_AND_SET 1
251 + static inline int testandset(volatile int *p)
252 + {
253 +        int ret;
254 +
255 +        __asm__ __volatile__("0: cs    %0,%1,0(%2)\n"
256 +                                                 "   jl    0b"
257 +                                                 : "=&d" (ret)
258 +                                                 : "r" (1), "a" (p), "0" (*p)
259 +                                                 : "cc", "memory" );
260 +        return ret;
261 + }
262 + #endif
263 +
264 + #ifdef __alpha__
265 + #define HAVE_TEST_AND_SET 1
266 + static inline int testandset(volatile int *p)
267 + {
268 +        int ret;
269 +        unsigned long one;
270 +
271 +        __asm__ __volatile__("0:        mov 1,%2\n"
272 +                                                 "      ldl_l %0,%1\n"
273 +                                                 "      stl_c %2,%1\n"
274 +                                                 "      beq %2,1f\n"
275 +                                                 ".subsection 2\n"
276 +                                                 "1:    br 0b\n"
277 +                                                 ".previous"
278 +                                                 : "=r" (ret), "=m" (*p), "=r" (one)
279 +                                                 : "m" (*p));
280 +        return ret;
281 + }
282 + #endif
283 +
284 + #ifdef __sparc__
285 + #define HAVE_TEST_AND_SET 1
286 + static inline int testandset(volatile int *p)
287 + {
288 +        int ret;
289 +
290 +        __asm__ __volatile__("ldstub    [%1], %0"
291 +                                                 : "=r" (ret)
292 +                                                 : "r" (p)
293 +                                                 : "memory");
294 +
295 +        return (ret ? 1 : 0);
296 + }
297 + #endif
298 +
299 + #ifdef __arm__
300 + #define HAVE_TEST_AND_SET 1
301 + static inline int testandset(volatile int *p)
302 + {
303 +        register unsigned int ret;
304 +        __asm__ __volatile__("swp %0, %1, [%2]"
305 +                                                 : "=r"(ret)
306 +                                                 : "0"(1), "r"(p));
307 +        
308 +        return ret;
309 + }
310 + #endif
311 +
312 + #endif /* __GNUC__ */
313 +
314 + typedef volatile int spinlock_t;
315 +
316 + static const spinlock_t SPIN_LOCK_UNLOCKED = 0;
317 +
318 + #if HAVE_TEST_AND_SET
319 + #define HAVE_SPINLOCKS 1
320 + static inline void spin_lock(spinlock_t *lock)
321 + {
322 +        while (testandset(lock));
323 + }
324 +
325 + static inline void spin_unlock(spinlock_t *lock)
326 + {
327 +        *lock = 0;
328 + }
329 +
330 + static inline int spin_trylock(spinlock_t *lock)
331 + {
332 +        return !testandset(lock);
333 + }
334 + #else
335 + static inline void spin_lock(spinlock_t *lock)
336 + {
337 + }
338 +
339 + static inline void spin_unlock(spinlock_t *lock)
340 + {
341 + }
342 +
343 + static inline int spin_trylock(spinlock_t *lock)
344 + {
345 +        return 1;
346 + }
347 + #endif
348 +
349 + /* X11 display fast locks */
350 + #ifdef HAVE_SPINLOCKS
351 + #define X11_LOCK_TYPE spinlock_t
352 + #define X11_LOCK_INIT SPIN_LOCK_UNLOCKED
353 + #define XDisplayLock() spin_lock(&x_display_lock)
354 + #define XDisplayUnlock() spin_unlock(&x_display_lock)
355 + #elif defined(HAVE_PTHREADS)
356 + #define X11_LOCK_TYPE pthread_mutex_t
357 + #define X11_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
358 + #define XDisplayLock() pthread_mutex_lock(&x_display_lock);
359 + #define XDisplayUnlock() pthread_mutex_unlock(&x_display_lock);
360 + #else
361 + #define XDisplayLock()
362 + #define XDisplayUnlock()
363 + #endif
364 + #ifdef X11_LOCK_TYPE
365 + extern X11_LOCK_TYPE x_display_lock;
366 + #endif
367 +
368 + #ifdef HAVE_PTHREADS
369 + /* Centralized pthread attribute setup */
370 + void Set_pthread_attr(pthread_attr_t *attr, int priority);
371 + #endif
372 +
373   /* UAE CPU defines */
374   #ifdef WORDS_BIGENDIAN
375  
# Line 218 | Line 410 | static inline void do_put_mem_word(uae_u
410  
411   #else /* WORDS_BIGENDIAN */
412  
413 < #ifdef __i386__
413 > #if defined(__i386__) || defined(__x86_64__)
414  
415   /* Intel x86 */
416   #define X86_PPRO_OPT
# Line 289 | Line 481 | static inline uae_u32 do_byteswap_16(uae
481   #define ENUMNAME(name) name
482   #define write_log printf
483  
484 < #ifdef X86_ASSEMBLY
484 > #if defined(X86_ASSEMBLY) || defined(X86_64_ASSEMBLY)
485   #define ASM_SYM_FOR_FUNC(a) __asm__(a)
486   #else
487   #define ASM_SYM_FOR_FUNC(a)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines