From: Ray Bryant <raybry@engr.sgi.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] cmpxchg patch
Date: Sat, 02 Feb 2002 16:26:42 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590698805982@msgid-missing> (raw)
[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]
It seems to me that the size of the result of cmpxchg(ptr,old,new)
should depend on the size of *ptr and not the size of old. For example,
see the following:
#include <stdio.h>
#define __SMP__
#define CONFIG_SMP
#include <asm/system.h>
typedef unsigned long long uint64_t;
uint64_t long lock=0xDEADBEEF00000000;
uint64_t long result;
main()
{
result = cmpxchg(&lock,0,1);
if (result == 0) printf("failed!!\n");
printf("sizeof(0)=%d sizeof(1)=%d\n",sizeof(0),sizeof(1));
result = cmpxchg(&lock,(uint64_t)0,1);
if (result != 0) printf("succeeded!!\n");
}
If you run this, you get
failed!!
succeeded!!
The problem is that cmpxchg() returns 0xDEADBEEF00000000 but then gcc
generates a sxt4 to truncate the result down to an int, which is the
size of old.
This is incorrect as near as I can tell.
Attached is a patch to fix.
--
Best Regards,
Ray
-----------------------------------------------
Ray Bryant SGI
512-453-9679 (work) 512-507-7807 (cell)
raybry@sgi.com raybry@austin.rr.com
Computers are like air conditioners.
They stop working when you open Windows.
-----------------------------------------------
[-- Attachment #2: cmpxchg.diff --]
[-- Type: text/plain, Size: 382 bytes --]
--- ./include/asm-ia64/system.h Sun Dec 23 02:58:36 2001
+++ /usr/people/raybry/tmp/system.h Sat Feb 2 07:53:26 2002
@@ -345,7 +345,7 @@
_r_ = __cmpxchg_called_with_bad_pointer(); \
break; \
} \
- (__typeof__(old)) _r_; \
+ (__typeof__(*ptr)) _r_; \
})
#define cmpxchg_acq(ptr,o,n) ia64_cmpxchg("acq", (ptr), (o), (n), sizeof(*(ptr)))
next reply other threads:[~2002-02-02 16:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-02 16:26 Ray Bryant [this message]
2002-02-05 1:35 ` [Linux-ia64] cmpxchg patch David Mosberger
2002-02-05 7:13 ` Ray Bryant
2002-02-05 19:22 ` David Mosberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-ia64-105590698805982@msgid-missing \
--to=raybry@engr.sgi.com \
--cc=linux-ia64@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.