473,750 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

32 or 64 bit processor info in C

Hello,

Is there a way in C to get information at runtime if a processor is 32
or 64 bit?

Cheers,

Broeisi

Apr 10 '07
168 7260

"Ian Collins" <ia******@hotma il.comwrote in message
news:58******** ******@mid.indi vidual.net...
Richard Heathfield wrote:
>Ian Collins said:
>>>When ever C hits the real world, developers have added fixed size
types.
Now they are standardised. Good.

Whenever language designers specify fixed size types, they have to come
back later and specify some more. Bad.
If don't specify the type, everyone else who wants it has to add their
own, so we ended up with typedefs like U8, INT16 and just about every
other possible naming of fixed types. At least the standard now sets a
naming convention.
People should be taught that it is almost never necessary to write code like
this.

Data is almost always either real numbers, strings, booleans, enumerated
symbols, or indices into arrays (technically a subset of keys). So double or
float, char *, and int should be basically all you need.
Almost always isn't alway always, and just occasionally you need an integer
of a different type. But it is very occasionally.

A cynic like me might argue that once you admit the size_t and ptrdif_t
gibberish into you code it is unreadable anyway and more gibberish won't
make any difference.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Apr 21 '07 #141
Malcolm McLean wrote:
>
"Ian Collins" <ia******@hotma il.comwrote in message
news:58******** ******@mid.indi vidual.net...
>Richard Heathfield wrote:
>>Ian Collins said:

When ever C hits the real world, developers have added fixed size
types.
Now they are standardised. Good.
Whenever language designers specify fixed size types, they have to come
back later and specify some more. Bad.
If don't specify the type, everyone else who wants it has to add their
own, so we ended up with typedefs like U8, INT16 and just about every
other possible naming of fixed types. At least the standard now sets a
naming convention.
People should be taught that it is almost never necessary to write code
like this.

Data is almost always either real numbers, strings, booleans, enumerated
symbols, or indices into arrays (technically a subset of keys). So
double or float, char *, and int should be basically all you need.
Never written any device drivers or protocol stacks then?

--
Ian Collins.
Apr 21 '07 #142
In article <1r************ *********@bt.co m>,
Malcolm McLean <re*******@btin ternet.comwrote :
>Data is almost always either real numbers, strings, booleans, enumerated
symbols, or indices into arrays (technically a subset of keys). So double or
float, char *, and int should be basically all you need.
Almost always isn't alway always, and just occasionally you need an integer
of a different type. But it is very occasionally.
I don't know what kind of programming you do, but the majority of
my programming over the years has been for integer data. Accounting
information for computer usage (time, disk, I/O). Network usage
analysis. Network trouble-shooting (e.g., number of late collisions).
Security log analysis (yes, that involves strings, but there are also
fundamental statistical summarization phases.) Compression programs
(string input, yes, but the output is integer arithmetic). And so on.

I have also worked on a number of scientic programs which used
real numbers extensively, so I am certainly not attempting to imply
that real numbers are unimportant, but the -majority- of my programs
have involved manipulating integral values.
--
Prototypes are supertypes of their clones. -- maplesoft
Apr 21 '07 #143
Ian Collins wrote:
Malcolm McLean wrote:
.... snip ...
>>
Data is almost always either real numbers, strings, booleans,
enumerated symbols, or indices into arrays (technically a subset
of keys). So double or float, char *, and int should be basically
all you need.

Never written any device drivers or protocol stacks then?
(val & 0xff) is fairly well guaranteed to carry exactly 8 bits.

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews

--
Posted via a free Usenet account from http://www.teranews.com

Apr 21 '07 #144
Walter Roberson wrote, On 21/04/07 13:02:
In article <1r************ *********@bt.co m>,
Malcolm McLean <re*******@btin ternet.comwrote :
>Data is almost always either real numbers, strings, booleans, enumerated
symbols, or indices into arrays (technically a subset of keys). So double or
float, char *, and int should be basically all you need.
Almost always isn't alway always, and just occasionally you need an integer
of a different type. But it is very occasionally.

I don't know what kind of programming you do, but the majority of
my programming over the years has been for integer data.
For me there has been a lot of fixed point stuff. I really do mean fixed
point, floating point would have been inappropriate for several reasons.
Accounting
information for computer usage (time, disk, I/O).
I can add accounting information in the sense accountants are interested
in as well. Also various other quantities, such as weights and measures,
for accounting, billing, invoicing reasons you want in fixed point with
a defined scaling rather than floating point.
Network usage
analysis. Network trouble-shooting (e.g., number of late collisions).
Security log analysis (yes, that involves strings, but there are also
fundamental statistical summarization phases.) Compression programs
(string input, yes, but the output is integer arithmetic). And so on.
A lot of embedded work in my experience you want fixed point for
efficiency. Also fixed point or integer is appropriate for certain types
of image processing, and for stability reasons (accurate control of
rounding and precision) you well prefer fixed point for all sorts of
control loops.
I have also worked on a number of scientic programs which used
real numbers extensively, so I am certainly not attempting to imply
that real numbers are unimportant, but the -majority- of my programs
have involved manipulating integral values.
Same here.
--
Flash Gordon
Apr 21 '07 #145
In article <46************ ***@yahoo.com>,
CBFalconer <cb********@mai neline.netwrote :
>Ian Collins wrote:
>Malcolm McLean wrote:
>>Data is almost always either real numbers, strings, booleans,
enumerated symbols, or indices into arrays (technically a subset
of keys). So double or float, char *, and int should be basically
all you need.
>Never written any device drivers or protocol stacks then?
>(val & 0xff) is fairly well guaranteed to carry exactly 8 bits.
But (val & 0xff) is not a "key" nor an "enumerated symbol", so
according to Malcolm it does not fall into the class of
"data is almost always". And there are a lot of IPv4 addresses
(and netmasks) still around; those are certain to fit into a C unsigned
long, but not certain to fit into a C "int"; to me it seems unnatural to
deliberately write the code in terms of arrays of unsigned char
or unsigned int just to fit into someone's notion that int
"should be basically all you need".
--
Programming is what happens while you're busy making other plans.
Apr 21 '07 #146
Ian Collins wrote, On 21/04/07 01:10:
Malcolm McLean wrote:
>"Eric Sosman" <Er*********@su n.comwrote in message
news:117710846 4.140009@news1n wk...
>>Malcolm McLean wrote On 04/20/07 17:58,:

change is not having int as the natural integer type for the platform.
You keep asserting this, but it was never so. int was
always a "useful" size that "made sense" for the platform.
I've used eight-bit machines with C implementations , but
never have I seen an 8-bit int.
Your machine had an eight bit address bus?
There is a bit of wooliness in the "natural integer type". However
generally it is the size needed to index the largest possible array,
which generally boils down to the size of the address bus, but not on
old x86s because of the weirdness of the architecture.

No, it can't do that, int is a signed type, so it can never index the
largest possible array.
Malcolm is also forgetting the Motorola 68000 series of processors. They
had address busses larger than 16 bits but smaller than 32 bits, they
were also flat address spaces. C compilers for those used 16 bit ints.

Some of the DSPs with 24 or 48 bit integer registers and ALUs will have
had 16/32 bit address busses. However, I suppose Malcolm might be happy
with an int larger than the address bus by a few bits.
>On a machine with 64 bits of flat address space and a 64 bit data
register file the natural integer size is quite clearly 64 bits. At the
moment there might be a performace case for using 32-bit integers to
conserve cache space. I've not said that all the good arguments are on
my side. However I suspect that this issue will prove to be quite
short-lived.
Considering 64 bit systems have been in widespread use for over a
decade, short is a relative term.
Indeed.
--
Flash Gordon
Apr 21 '07 #147

"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:5p******** ****@news.flash-gordon.me.uk...
>
Some of the DSPs with 24 or 48 bit integer registers and ALUs will have
had 16/32 bit address busses. However, I suppose Malcolm might be happy
with an int larger than the address bus by a few bits.
Ideally you'd have one extra bit so that signed arithmetic couldn't fail to
have enough resolution. However at least in C the convention is that indices
are scaled by the data type. So the problem only arises for char arrays
taking up over half the address space. That happens rarely enough for it to
be reasonable to say "many functions may not work on your dataset, you will
have to code specially with unsigned types".
Most architectures don't distinguish between address and data integer
registers, so it makes sense to use the same registers to hold pointers and
ints.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
Apr 21 '07 #148
In article <C_************ *************** ***@bt.com>,
Malcolm McLean <re*******@btin ternet.comwrote :
>Most architectures don't distinguish between address and data integer
registers, so it makes sense to use the same registers to hold pointers and
ints.
"Most" maybe, but some well known and widely implemented architectures
do, such as the Motorola 680x0 and the MIPS R2000/ 3000/ 4000/ 5000/
6000/ 8000/ 10000/ 12000 lines (MIPS is used in a lot of embedded
situations, I hear.)

Are we talking about C for general purpose computing, or are we talking
about imposing non-trivial architecture restrictions on the machines
that will use this modified C?
--
All is vanity. -- Ecclesiastes
Apr 21 '07 #149

"Walter Roberson" <ro******@ibd.n rc-cnrc.gc.cawrote in message
news:f0******** **@canopus.cc.u manitoba.ca...
In article <C_************ *************** ***@bt.com>,
Malcolm McLean <re*******@btin ternet.comwrote :
>>Most architectures don't distinguish between address and data integer
registers, so it makes sense to use the same registers to hold pointers
and
ints.

"Most" maybe, but some well known and widely implemented architectures
do, such as the Motorola 680x0 and the MIPS R2000/ 3000/ 4000/ 5000/
6000/ 8000/ 10000/ 12000 lines (MIPS is used in a lot of embedded
situations, I hear.)

Are we talking about C for general purpose computing, or are we talking
about imposing non-trivial architecture restrictions on the machines
that will use this modified C?
We're talking about what int should be on a typical 64-bit machine. I'm
arguing 64 bits, the emerging convention is 32 bits, which I oppose. We're
not taling about removing latitude from the language so that DSP chips and
the like can't use funny integer sizes if it is appropriate for them, nor
are we talking about modifying the standard.
Except that I've indicated that as a long-term goal I'd like size_t removed
from the language, or at least generate a mandatory ugliness warning.
However that's for the future. At the moment the fight is for 64 bits.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Apr 21 '07 #150

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

Similar topics

5
5237
by: dba_db2 at nospam gmx.net | last post by:
We have got a brand new mutltiprocessor machine IBM pseries server with 2 processors. Now we want to buy a IBM DB2 license for this box. Does anyone know whether it is possible to buy a single processor db2 license for this machine and to configure the db2 software with db2licm just to use one processor.
1
3476
by: Mateusz Rajca | last post by:
Hello, I would like to know how to find the specs of the current running system such as the memory amount and processor speed in C#? Mateusz
3
1441
by: Michel Meex | last post by:
Hello, I have an application, that has been running on a single processor server for more then a year without any problems. Now I'm migrating to a dual processor server, and I'm experiencing problems with threading. The application is actually a kind of job schedular. For all jobs, I can set a recurring interval (daily,weekly, monthly etc) at which the specific job should be started. We program each job, according to an interface....
1
1401
by: Michel Meex | last post by:
Hello, I have an application, that has been running on a single processor server for more then a year without any problems. Now I'm migrating to a dual processor server, and I'm experiencing problems with threading. The application is actually a kind of job schedular. For all jobs, I can set a recurring interval (daily,weekly, monthly etc) at which the specific job should be started. We program each job, according to an interface....
11
2320
by: sunil | last post by:
Dear All, I have created a .Net service in 2.0 and running it on a machine that has a Quad Processor. It is failing with the following error. "Error 1053: The service did not respond to the start or control request in a timely fashion" This is what I saw in event Viewer. Timeout (30000 milliseconds) waiting for the MyService Server service to connect.
5
6590
by: nano2k | last post by:
Hi I need to protect my application in a way. Just a "soft" protection, not a very strong one. So, using WMI I get the processor ID and compare it against a key. Protection works well, until someone (me) decides to clone the system. After cloning, all cloned systems work with the same key. That is, WMI returns the same processor id on all workstations. It seems that Windows "caches" the processor ID in the registry or somewhere else - I...
10
7009
by: WannaKatana | last post by:
I am just wondering why, with nothing else running and executing an update query against a very large table, does Access seem to be causing less than 10% processor usage. Then it says "There is not enough disk space or memory to undo the changes". I have 2 gb RAM, Core 2 duo e6300 processor and plenty of disk space. Why doesn't Access peg the CPU? Joel
11
6493
by: kyosohma | last post by:
Hi, We use a script here at work that runs whenever someone logs into their machine that logs various bits of information to a database. One of those bits is the CPU's model and speed. While this works in 95% of the time, we have some fringe cases where the only thing returned is the processor name. We use this data to help us decide which PCs need to be updated, so it would be nice to have the processor speed in all cases.
2
6178
by: raghavv | last post by:
Hi, I have developed a software.For licensing it i need to access a unique number of a computer like mother board id or processor id. Is there a way to get this info.In C# we can use system.management to get this info.Is there anything similar to this in java. If not How can i do this. Thank you...
0
8999
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
8836
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,...
1
9338
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,...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6080
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
4712
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
3322
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
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2223
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.