Subversion Repositories Kolibri OS

Rev

Rev 1964 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1964 Rev 3031
Line 264... Line 264...
264
 
264
 
265
typedef struct {
265
typedef struct {
266
	u64 __aligned(8) counter;
266
	u64 __aligned(8) counter;
Line 267... Line -...
267
} atomic64_t;
-
 
-
 
267
} atomic64_t;
Line 268... Line 268...
268
 
268
 
Line 269... Line 269...
269
#define ATOMIC64_INIT(val)	{ (val) }
269
 
270
 
270
 
Line 276... Line 276...
276
 * @new_val:  value to assign
276
 * @new_val:  value to assign
277
 *
277
 *
278
 * Atomically xchgs the value of @ptr to @new_val and returns
278
 * Atomically xchgs the value of @ptr to @new_val and returns
279
 * the old value.
279
 * the old value.
280
 */
280
 */
281
extern u64 atomic64_xchg(atomic64_t *ptr, u64 new_val);
281
static inline long long atomic64_xchg(atomic64_t *v, long long n)
-
 
282
{
-
 
283
    long long o;
-
 
284
    unsigned high = (unsigned)(n >> 32);
-
 
285
    unsigned low = (unsigned)n;
-
 
286
 
-
 
287
    asm volatile(
-
 
288
    "1:                 \n\t"
-
 
289
    "cmpxchg8b (%%esi)  \n\t"
-
 
290
    "jnz 1b             \n\t"
-
 
291
    :"=&A" (o)
-
 
292
    :"S" (v), "b" (low), "c" (high)
-
 
293
    : "memory", "cc");
-
 
294
    return o;
-
 
295
}
Line 282... Line 296...
282
 
296
 
283
/**
297
/**
284
 * atomic64_set - set atomic64 variable
298
 * atomic64_set - set atomic64 variable
285
 * @ptr:      pointer to type atomic64_t
299
 * @ptr:      pointer to type atomic64_t
286
 * @new_val:  value to assign
300
 * @new_val:  value to assign
287
 *
301
 *
288
 * Atomically sets the value of @ptr to @new_val.
302
 * Atomically sets the value of @ptr to @new_val.
-
 
303
 */
289
 */
304
 
-
 
305
static inline void atomic64_set(atomic64_t *v, long long i)
-
 
306
{
-
 
307
    unsigned high = (unsigned)(i >> 32);
-
 
308
    unsigned low = (unsigned)i;
-
 
309
    asm volatile (
-
 
310
    "1:                 \n\t"
-
 
311
    "cmpxchg8b (%%esi)  \n\t"
-
 
312
    "jnz 1b             \n\t"
-
 
313
    :
-
 
314
    :"S" (v), "b" (low), "c" (high)
-
 
315
    : "eax", "edx", "memory", "cc");
-
 
316
}
Line 290... Line 317...
290
extern void atomic64_set(atomic64_t *ptr, u64 new_val);
317
 
291
 
318
 
292
/**
319
/**
293
 * atomic64_read - read atomic64 variable
320
 * atomic64_read - read atomic64 variable
Line 315... Line 342...
315
		);
342
		);
Line 316... Line 343...
316
 
343
 
317
	return res;
344
	return res;
Line 318... Line -...
318
}
-
 
Line 319... Line 345...
319
 
345
}
320
extern u64 atomic64_read(atomic64_t *ptr);
346
 
321
 
347
 
322
/**
348
/**