pcpu.h (9b4fcf851a73554063d4a2de9a4f10cd23a0a4f6) pcpu.h (e93d0cbef142a2c6276ae83390a2ea81f0889b43)
1/*-
2 * Copyright (c) Peter Wemm
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 222 unchanged lines hidden (view full) ---

231} while (0)
232
233#define PCPU_GET(member) __PCPU_GET(pc_ ## member)
234#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
235#define PCPU_INC(member) __PCPU_INC(pc_ ## member)
236#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
237#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
238
1/*-
2 * Copyright (c) Peter Wemm
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 222 unchanged lines hidden (view full) ---

231} while (0)
232
233#define PCPU_GET(member) __PCPU_GET(pc_ ## member)
234#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
235#define PCPU_INC(member) __PCPU_INC(pc_ ## member)
236#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
237#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
238
239#define OFFSETOF_CURTHREAD 0
240#ifdef __clang__
241#pragma clang diagnostic push
242#pragma clang diagnostic ignored "-Wnull-dereference"
243#endif
239static __inline __pure2 struct thread *
240__curthread(void)
241{
242 struct thread *td;
243
244static __inline __pure2 struct thread *
245__curthread(void)
246{
247 struct thread *td;
248
244 __asm("movl %%fs:0,%0" : "=r" (td));
249 __asm("movl %%fs:%1,%0" : "=r" (td)
250 : "m" (*(char *)OFFSETOF_CURTHREAD));
245 return (td);
246}
251 return (td);
252}
253#ifdef __clang__
254#pragma clang diagnostic pop
255#endif
247#define curthread (__curthread())
248
256#define curthread (__curthread())
257
258#define OFFSETOF_CURPCB 16
259static __inline __pure2 struct pcb *
260__curpcb(void)
261{
262 struct pcb *pcb;
263
264 __asm("movl %%fs:%1,%0" : "=r" (pcb) : "m" (*(char *)OFFSETOF_CURPCB));
265 return (pcb);
266}
267#define curpcb (__curpcb())
268
249#else /* !lint || defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) */
250
251#error "this file needs to be ported to your compiler"
252
253#endif /* lint, etc. */
254
255#endif /* _KERNEL */
256
257#endif /* !_MACHINE_PCPU_H_ */
269#else /* !lint || defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) */
270
271#error "this file needs to be ported to your compiler"
272
273#endif /* lint, etc. */
274
275#endif /* _KERNEL */
276
277#endif /* !_MACHINE_PCPU_H_ */