473,480 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

<time .h> in the standard,Why?

Friends,
As I was going through the standard draft of C (C99) I come across
the header file <time.h>. I wonder why the standard has included the
header file since it depends on the hardware that we work with. If
somebody wants to access the time of the system then he has to use the
interrupt 1A in the real mode or access the timer chip (port id
70-70h) pmode but that is off-topic in this group.
I concluded that it is because of the running-time analysis that is
needed for a program.
(Correct me if I am wrong)
If the standard can include a *portable* way of accessing a hardware
why not the standard include for other routines also such as keyboard,
graphic device drivers, hard disk etc.
Nov 14 '05 #1
5 1909
hi,
The design of C is not to hide the hardware but to provide a general way
of programming on different platforms.
C runs on real system not the virtual machine.So almost every action has
something to do with the hardware. Standard I/O, setjmp, math lib....
In your question, the time library may be support by the hardware or the
OS or anything else, depending on the compiler and system architecture.
There is no *protable* way to access hardware, but *portable* software
interface implemented by compiler and libc.
"sathyashrayan" <sa************@yahoo.co.in> ????
news:23**************************@posting.google.c om...
Friends,
As I was going through the standard draft of C (C99) I come across
the header file <time.h>. I wonder why the standard has included the
header file since it depends on the hardware that we work with. If
somebody wants to access the time of the system then he has to use the
interrupt 1A in the real mode or access the timer chip (port id
70-70h) pmode but that is off-topic in this group.
I concluded that it is because of the running-time analysis that is
needed for a program.
(Correct me if I am wrong)
If the standard can include a *portable* way of accessing a hardware
why not the standard include for other routines also such as keyboard,
graphic device drivers, hard disk etc.


Nov 14 '05 #2
On 3 Feb 2004 18:52:16 -0800, sa************@yahoo.co.in
(sathyashrayan) wrote in comp.lang.c:
Friends,
As I was going through the standard draft of C (C99) I come across
the header file <time.h>. I wonder why the standard has included the
header file since it depends on the hardware that we work with. If
Do you think so? Why do you think so? Do you think there is only one
hardware computer platform in the entire universe?
somebody wants to access the time of the system then he has to use the
interrupt 1A in the real mode or access the timer chip (port id
There are many, many computers out there that don't have an "interrupt
1A", or "real mode".
70-70h) pmode but that is off-topic in this group.
Or "port id" anything, or "pmode".

None of these things on any Macintosh or SparcStation, just to name a
few.
I concluded that it is because of the running-time analysis that is
needed for a program.
(Correct me if I am wrong)
You are wrong.
If the standard can include a *portable* way of accessing a hardware
why not the standard include for other routines also such as keyboard,
graphic device drivers, hard disk etc.


Why do you think that this has anything to do with accessing hardware,
let alone specific hardware in one specific type of computer? Opening
and reading a file does not access hardware, at least not as far as C
is concerned. The underlying platform how to connect that stream to
some device or other.

On many networks, all computers update their notion of real-world time
from a designated server. There are time servers on the Internet as
well. Computers with no hardware time-of-day clock could get their
time from them.

Nor does the existence of the function time() even require that all
computers be able to provide this value. An implementation merely
returns time_t(-1) if it cannot.

Your horizon of both computer hardware and computer programming are
far too narrow, almost tragically so.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #3
On Tue, 3 Feb 2004, sathyashrayan wrote:
Friends,
As I was going through the standard draft of C (C99) I come across
the header file <time.h>. I wonder why the standard has included the
header file since it depends on the hardware that we work with. If
somebody wants to access the time of the system then he has to use the
interrupt 1A in the real mode or access the timer chip (port id
70-70h) pmode but that is off-topic in this group.
I concluded that it is because of the running-time analysis that is
needed for a program.
(Correct me if I am wrong)
Consider yourself corrected. The time.h header files is there because
there is a standard set of functions associated with time and clocks. This
is nothing new to the C standard.
If the standard can include a *portable* way of accessing a hardware
why not the standard include for other routines also such as keyboard,
graphic device drivers, hard disk etc.


If I take a moment and think about it, I am hard pressed to thing of a
system that does not have some sort of clock or timer on it. The standard
has allowed for systems that don't have a clock but I believe the norm is
for a system to have a clock.

I'm looking at four development systems on my desk that have no keyboard,
no graphics and no hard drive support. Many of the systems I work with are
like this. When I do a printf the standard output is to a memory buffer
and a signal pin to let the host computer know there is data in the C I/O
buffer ready for retrieval. My development environment retrieves the data
from the target computer and displays it on the host computer.

I have no need for graphic drivers or hard drive support. There is an
entire world of development out there that is very different from Windows,
UNIX and MacOS.

NOTE: there are libraries, like curses, that are supported by many
platforms. They attempt to do for displays what time.h does for
clocks/timers.

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #4
In <23**************************@posting.google.com > sa************@yahoo.co.in (sathyashrayan) writes:
As I was going through the standard draft of C (C99) I come across
the header file <time.h>. I wonder why the standard has included the
header file since it depends on the hardware that we work with.
That's precisely why it was included in the standard. <time.h> is no
different from <stdio.h> from this point of view: both hide the
hardware/OS specific details and provide an implementation-neutral
interface to the application programmer.
If
somebody wants to access the time of the system then he has to use the
interrupt 1A in the real mode or access the timer chip (port id
70-70h) pmode but that is off-topic in this group.


And completely useless to people who don't program on PC hardware, as
well as to people who do program on PC hardware, but whose OS doesn't
allow direct access to the hardware ports.

While <time.h> works for everybody, the same way, as long as the
underlying hardware can keep track of the wall clock time.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5
Zhi Liu wrote:
hi,
The design of C is not to hide the hardware but to provide a general way
of programming on different platforms.
C runs on real system not the virtual machine.So almost every action has
something to do with the hardware. Standard I/O, setjmp, math lib....
In your question, the time library may be support by the hardware or the
OS or anything else, depending on the compiler and system architecture.
There is no *protable* way to access hardware, but *portable* software
interface implemented by compiler and libc.
This is correct, but top-posting like you just did is considered rude.

Do as I'm doing now, and as most people here do, and put your reply
/below/ the text you are replying to. It makes it much, much easier for
people to follow the thread of the conversation.

So, to put it briefly, you could really make a big hit here (in a good
way :) ) if you just put your text below what you are replying to.

Thanks.


"sathyashrayan" <sa************@yahoo.co.in> ????
news:23**************************@posting.google.c om...
Friends,
As I was going through the standard draft of C (C99) I come across
the header file <time.h>. I wonder why the standard has included the
header file since it depends on the hardware that we work with. If
somebody wants to access the time of the system then he has to use the
interrupt 1A in the real mode or access the timer chip (port id
70-70h) pmode but that is off-topic in this group.
I concluded that it is because of the running-time analysis that is
needed for a program.
(Correct me if I am wrong)
If the standard can include a *portable* way of accessing a hardware
why not the standard include for other routines also such as keyboard,
graphic device drivers, hard disk etc.


--
My address is yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
Note: Rot13 and convert spelled-out numbers to numerical equivalents.
Nov 14 '05 #6

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

Similar topics

2
10530
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
1
1136
by: red floyd | last post by:
In the August 2004 CUJ, Sutter&Hyslop's column implies that shared_ptr<> has become part of the standard. Is the revised standard finalized? Am I correct in assuing that shared_ptr<> will be...
4
4480
by: Jurko Gospodnetić | last post by:
Hi all. I was wondering. Can the standard basic_string<> c_str() member function throw any exceptions? Is it perhaps implementation dependent? I tried checking the standard and as far as I...
18
2610
by: Tuckers | last post by:
My question is, if I have created my own library which lives in its own install directory, to refer to its header file is it better to use #include "MyLibrary.h" or #include <MyLibrary.h> ...
1
7665
by: Robert Dodier | last post by:
Hello, Sorry for asking what must be a FAQ, but I wasn't able to find the answer. I have an XML document fragment which I want to store as a text string. I want a function to convert any XML...
4
2357
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
2
5269
by: cremoni | last post by:
STL has a hash function documented here: http://www.sgi.com/tech/stl/hash.html What header do I include? I can't find it defined anywhere in the MSVC headers. I'm using MSVC8, BTW. Sorry if...
3
3342
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
14
3115
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the...
0
6920
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...
0
7060
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,...
0
7106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6760
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...
0
7022
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4799
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...
0
3013
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...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.