473,770 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AMD opteron 64

Hello,

I have a test program that is compiled fine on a 32 bits redhat linux using gcc :
*************** ********
main (argc, argv)
int argc;
char *argv[];
{
int *ka;
int nka;

/* allocation dynamique entiere */
ka = (int *) malloc(nka * sizeof(int));
if (!ka) {
printf ("<ERROR> : Out of heap space (malloc) !\n");
printf ("<ERROR> : %d int words required\n", nka);
exit (-1);
}
}
*************** ********

But under linux suse AMD opteron 64, i get this message from the compiler :

warning: cast to pointer from integer of different size

Any explanation ?

Regards,
Lionel.
--
-=O=------------------------------------------=O=-
Lionel Valéro
Analyste Informatique Département Génie Chimique
École Polytechnique de Montréal
C.P. 6079, succ. centre-ville
Montréal (Québec) H3C 3A7
Tel: (514) 340 - 4711 # 4805 / C552
Fax: (514) 340 - 4159
-=O=------------------------------------------=O=-

Nov 13 '05
54 3592
In <87************ @pfaff.stanford .edu> Ben Pfaff <bl*@cs.stanfor d.edu> writes:
Instead, write it this way:

int *x = malloc (sizeof *x * 128);


Or, more readably:

int *x = malloc(128 * sizeof *x);

which tells to the human reader: I want to allocate space for 128 items
of that size.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #21
Lionel Valero <li***********@ polymtl.ca> wrote:
I have a test program that is compiled fine on a 32 bits redhat linux using gcc :
*************** ********
main (argc, argv)
int argc;
char *argv[];
{
int *ka;
int nka;

/* allocation dynamique entiere */
ka = (int *) malloc(nka * sizeof(int));
if (!ka) {
printf ("<ERROR> : Out of heap space (malloc) !\n");
printf ("<ERROR> : %d int words required\n", nka);
exit (-1);
}
}
*************** ********

But under linux suse AMD opteron 64, i get this message from the compiler :

warning: cast to pointer from integer of different size

Any explanation ?


Well, the #include <...> headers that others have posted about will
fix the problem (the compiler thinks that malloc returns a 32bit int
because you didn't include a header file that says otherwise.)

But of course you have an additional problem that you did not define
the value of nka. Which is going to be another serious problem for
you to get the code working.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
Nov 13 '05 #22
Sorry,

this code is a peace of code taken from a bigger one, i should have instancied
nka value to make it clearer.

Paul Hsieh wrote:
Lionel Valero <li***********@ polymtl.ca> wrote:
I have a test program that is compiled fine on a 32 bits redhat linux using gcc :
************* **********
main (argc, argv)
int argc;
char *argv[];
{
int *ka;
int nka;

/* allocation dynamique entiere */
ka = (int *) malloc(nka * sizeof(int));
if (!ka) {
printf ("<ERROR> : Out of heap space (malloc) !\n");
printf ("<ERROR> : %d int words required\n", nka);
exit (-1);
}
}
************* **********

But under linux suse AMD opteron 64, i get this message from the compiler :

warning: cast to pointer from integer of different size

Any explanation ?

Well, the #include <...> headers that others have posted about will
fix the problem (the compiler thinks that malloc returns a 32bit int
because you didn't include a header file that says otherwise.)

But of course you have an additional problem that you did not define
the value of nka. Which is going to be another serious problem for
you to get the code working.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/


--
-=O=------------------------------------------=O=-
Lionel Valéro
Analyste Informatique Département Génie Chimique
École Polytechnique de Montréal
C.P. 6079, succ. centre-ville
Montréal (Québec) H3C 3A7
Tel: (514) 340 - 4711 # 4805 / C552
Fax: (514) 340 - 4159
-=O=------------------------------------------=O=-
Nov 13 '05 #23
Barry Schwarz wrote:
On a machine where the method of returning a pointer
differs from the method of returning an int
(such as using a different register),
Please tell us which machine does this.
the behavior is indeed undefined.
malloc will return the pointer using the correct procedure.
The compiler will generate code to convert the assumed returned int.
Since malloc did not return an int,
this code will operate on residual data.


Could you please code up an example
and run it on the machine that you reference above
so that we can see how it fails?

Nov 13 '05 #24
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
Eric Sosman <Er*********@su n.com> scribbled the following:
"E. Robert Tisdale" wrote:
> Ben Pfaff wrote:
> > I don't recommend casting the return value of malloc():
> >
> > * The cast is not required in ANSI C.
>
> But an ANSI/ISO C++ compiler will complain.


Which proves once again that C++ is broken, since the cast is useless
and useless casts should be anathema.


<OT>
C++ is a different language than C, and there are valid reasons that
C++ disallows implicit conversions from void* to other pointer types.
These reasons don't apply to C. For details, see elsewhere.
</OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 13 '05 #25
In <79************ **************@ posting.google. com> qe*@pobox.com (Paul Hsieh) writes:
Lionel Valero <li***********@ polymtl.ca> wrote:
I have a test program that is compiled fine on a 32 bits redhat linux using gcc :
*************** ********
main (argc, argv)
int argc;
char *argv[];
{
int *ka;
int nka;

/* allocation dynamique entiere */
ka = (int *) malloc(nka * sizeof(int));
if (!ka) {
printf ("<ERROR> : Out of heap space (malloc) !\n");
printf ("<ERROR> : %d int words required\n", nka);
exit (-1);
}
}
*************** ********

But under linux suse AMD opteron 64, i get this message from the compiler :

warning: cast to pointer from integer of different size

Any explanation ?


Well, the #include <...> headers that others have posted about will
fix the problem (the compiler thinks that malloc returns a 32bit int
because you didn't include a header file that says otherwise.)

But of course you have an additional problem that you did not define
the value of nka. Which is going to be another serious problem for
you to get the code working.


I don't think that initialising nka is such a serious problem. Most
likely, this is the trimmed down version of his real program and he
trimmed too much.

What I find surprising is that, in this day and age, people still use
old style function definitions. Have they been asleep for the last 15
years or what?

And, while I can easily understand the usage of exit(1) to signal
failure (common convention under Unix and MSDOS), the usage of exit(-1)
keeps baffling me: I have yet to see a single implementation where the
value -1 is passed as such to the entity that launched the execution
of the program in question.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #26
In <3F************ **@jpl.nasa.gov > "E. Robert Tisdale" <E.************ **@jpl.nasa.gov > writes:
Barry Schwarz wrote:
On a machine where the method of returning a pointer
differs from the method of returning an int
(such as using a different register),


Please tell us which machine does this.


The x86 in certain memory models, where an int is 16 bits and a pointer
is 32 bits.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #27
Dan Pop wrote:
E. Robert Tisdale writes:
Barry Schwarz wrote:
On a machine where the method of returning a pointer
differs from the method of returning an int
(such as using a different register),


Please tell us which machine does this.


The x86 in certain memory models
where an int is 16 bits and a pointer is 32 bits.


Could you please code up an example
and run it on the machine that you reference above
so that we can see how it fails?


Nov 13 '05 #28
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > writes:
Barry Schwarz wrote:
On a machine where the method of returning a pointer
differs from the method of returning an int
(such as using a different register),


Please tell us which machine does this.


One example is gcc on IA-64 Linux, which has 64-bit pointers and
32-bit ints. (It doesn't use a different register, but the size
mismatch causes similar problems.)
the behavior is indeed undefined.
malloc will return the pointer using the correct procedure.
The compiler will generate code to convert the assumed returned int.
Since malloc did not return an int,
this code will operate on residual data.


Could you please code up an example
and run it on the machine that you reference above
so that we can see how it fails?


I did this some time ago; search the archives.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 13 '05 #29
E. Robert Tisdale wrote:
Barry Schwarz wrote:
On a machine where the method of returning a pointer
differs from the method of returning an int
(such as using a different register),

Please tell us which machine does this.


Any machine where sizeof(int) is different than sizeof(char*) will do.

Though this is more OS or function calling convention dependent than
machine dependent.

-- glen

Nov 13 '05 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1431
by: jacob nikom | last post by:
Hi, We ran MySQL (4.0.15-standard, 64-bit, SuSe 8.0) benchmarks on 2 CPU and 4 CPU Opteron machines. Mostly we tested insertion times with many simultaneous connections (hundreds). To our surprise we did not find significant differences. Each of our servers (2 and 4 CPU machine) has one 1Gbit network connection. I have feelings that the machines are the network bounded, not the CPU bounded. Could it be true? How to verify it?
0
519
by: Plymouth Acclaim | last post by:
Hi guys, We have a problem with Dual AMD64 Opteron/MySQL 4.0.18/Mandrake 10 for a very high volume site. We are evaluating the performance on our new server AMD64 and it seems it's slow compared to Dual Xeon/MySQL 4.0.15/RedHat8 and Dual Xeon/MySQL 4.0.18/Mandrake 10. And it seems there are zombie threads. 570 threads in 1 hour and we didn't even use JDBC connection pooling at all. These threads are supposed to be gone within 60...
1
1446
by: Rajrup Banerjee | last post by:
Hi, Does anybody know what are the changes to be done to compile C++ code which uses stl from SGI STL library, using g++ 3.2.3, on Linux running on AMD Opteron 64 bit? Regards, Rajrup.
1
1876
by: louis_pastorik | last post by:
Does anyone have any information about 64 bit python support for Xeon and Opteron architectures on Windows platforms? If anyone has built the python runtime on either of these platforms before I would be really interested. Thanks.
1
2333
by: Ericson Smith | last post by:
Hi, We're thinking of moving to a 64 bit platform for our database. Does anyone have any stories of migration from 32 bit to 64 bits? * How did it impact performance? * Were there any gochas? * What processors were used (any AMD Opteron's so far?) Also what kind of performance increase could we expect if we moved from a dual 32 bit to a quad 32 bit platform. (We are already using speedy
0
1222
by: J.Haan | last post by:
Hi all, at the company where I work, we're planning on installing DB2 on an AMD Opteron with 32GB of memory. Let's say we're running DB2 8.1 FP 7 in 64bit mode on SuSE Linux Enterprise Server 9.0. Can we create bufferpools with a size over 4GB? Let's say 12GB? Has anyone got any experience running such a configuration?
3
2264
by: ashokrathi | last post by:
I am trying to compile SQL procedures on Linux running on AMD/Opteron 64-bit machine. I have 'gcc', 'cc' and 'g++' compilers on my machine. I have set DB2_SQLROUTINE_COMPILE_COMMAND with various options, such as, db2set DB2_SQLROUTINE_COMPILE_COMMAND="gcc -fPIC -$HOME/sqllib/include SQLROUTINE_FILENAME.c -shared -o SQLROUTINE_FILENAME -L$HOME/sqllib/lib -ldb2" I have tried with/without "-fPIC" option. Without "-fPIC", I get following...
1
1545
by: Rocael Hernandez | last post by:
Hello all, I was wondering what's best for PG, since we have to decide what will be the new server for our DB, that will serve one or more websites. Our actual configuration is a dual xeon 2.8ghz with 4Gb ram + scsi disks, and works fine, though some intensive insert/update processes has taken it to 100% cpu use.
4
2340
by: LLessieux | last post by:
Hi, I have been seeing a strange behaviour when doing some tests on a Dual - Dual Core Opteron system using Windows XP (32bits with SP2). In out application we have a wrapper around the thread pool to handle the work on renderers and CPU intensive tasks. On the Dual - Dual Core Opteron, the application is correctly starting 4 threads but it seems to be running only 2 concurrently.
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.