SilcBool silc_atomic_cas32(SilcAtomic32 *atomic, SilcUInt32 old_val,
SilcUInt32 new_val)
{
- SilcUInt32 ret;
-
#if !defined(SILC_THREADS)
/* No atomic operations */
if (atomic->value == old_val) {
#elif defined(__GNUC__) && (defined(SILC_I486) || defined(SILC_X86_64))
/* GCC + i486 or x86_64 */
+ SilcUInt32 ret;
__asm __volatile("lock; cmpxchgl %2, %1"
: "=a" (ret), "=m" (atomic->value)
: "r" (new_val), "m" (atomic->value), "0" (old_val));
SilcBool silc_atomic_cas16(SilcAtomic16 *atomic, SilcUInt16 old_val,
SilcUInt16 new_val)
{
- SilcUInt16 ret;
-
#if !defined(SILC_THREADS)
/* No atomic operations */
if (atomic->value == old_val) {
#elif defined(__GNUC__) && (defined(SILC_I486) || defined(SILC_X86_64))
/* GCC + i486 or x86_64 */
+ SilcUInt16 ret;
__asm __volatile("lock; cmpxchgw %2, %1"
: "=a" (ret), "=m" (atomic->value)
: "c" (new_val), "m" (atomic->value), "0" (old_val));
SilcBool silc_atomic_cas8(SilcAtomic8 *atomic, SilcUInt8 old_val,
SilcUInt8 new_val)
{
- SilcUInt8 ret;
-
#if !defined(SILC_THREADS)
/* No atomic operations */
if (atomic->value == old_val) {
#elif defined(__GNUC__) && (defined(SILC_I486) || defined(SILC_X86_64))
/* GCC + i486 or x86_64 */
+ SilcUInt8 ret;
__asm __volatile("lock; cmpxchgb %2, %1"
: "=a" (ret), "=m" (atomic->value)
: "c" (new_val), "m" (atomic->value), "0" (old_val));
SilcBool silc_atomic_cas_pointer(SilcAtomicPointer *atomic, void *old_val,
void *new_val)
{
- void *ret;
-
#if !defined(SILC_THREADS)
/* No atomic operations */
if (atomic->pointer == old_val) {
#elif defined(__GNUC__) && defined(SILC_I486)
/* GCC + i486 */
+ void *ret;
__asm __volatile("lock; cmpxchgl %2, %1"
: "=a" (ret), "=m" (atomic->pointer)
: "c" (new_val), "m" (atomic->pointer), "0" (old_val));
#elif defined(__GNUC__) && defined(SILC_X86_64)
/* GCC + x86_64 */
+ void *ret;
__asm __volatile("lock; cmpxchgq %q2, %1"
: "=a" (ret), "=m" (atomic->pointer)
: "c" (new_val), "m" (atomic->pointer), "0" (old_val));
Author: Giovanni Giacobbi <giovanni@giacobbi.net>
- Copyright (C) 2002 - 2003 Giovanni Giacobbi
+ Copyright (C) 2002 - 2006 Giovanni Giacobbi
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static void my_trim_spaces(SilcConfigFile *file)
{
register char *r = file->p;
- while ((*r != '\0' && *r != EOF) && isspace(*r))
+ while ((*r != '\0' && *r != EOF) && isspace((int)*r))
if (*r++ == '\n') file->line++;
file->p = r;
}
register char *o;
my_trim_spaces(file);
o = file->p;
- while (isalnum(*o) || (*o == '_') || (*o == '-'))
+ while (isalnum((int)*o) || (*o == '_') || (*o == '-'))
*to++ = *o++;
*to = '\0';
file->p = o;
if (val == val_tmp)
return NULL; /* really wrong, there must be at least one digit */
/* Search for a designator */
- switch (tolower(val_tmp[0])) {
+ switch (tolower((int)val_tmp[0])) {
case '\0': /* None */
break;
case 'k': /* Kilobytes */