mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-22 07:30:54 +00:00
Make CLOCKS_PER_SEC and CLK_TCK work in 50Hz video mode.
Previously, they were hard-coded as 60, but the clock tick frequency actually depends on the video mode. They now call a new library function that can detect the video mode and return the proper value. This also makes CLOCKS_PER_SEC have the type clock_t, as C99 and later require.
This commit is contained in:
parent
2b9d332580
commit
aa5b239824
@ -28,10 +28,11 @@ struct tm {
|
||||
int tm_isdst;
|
||||
};
|
||||
|
||||
clock_t __clocks_per_sec(void);
|
||||
#ifndef __KeepNamespacePure__
|
||||
#define CLK_TCK 60
|
||||
#define CLK_TCK (__clocks_per_sec())
|
||||
#endif
|
||||
#define CLOCKS_PER_SEC 60
|
||||
#define CLOCKS_PER_SEC (__clocks_per_sec())
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *) 0L
|
||||
|
6
cc.notes
6
cc.notes
@ -254,6 +254,10 @@ p. 344
|
||||
|
||||
The atexit() function actually returns zero if the function is registered successfully, and a non-zero value if there is not enough memory to satisfy the request (the reverse of what the manual says).
|
||||
|
||||
p. 348
|
||||
|
||||
The discussion of clock() should mention the standard macro CLOCKS_PER_SEC, which gives the number of clock ticks per second. The CLK_TCK macro also gives the same value, but it is non-standard and should be considered deprecated. Also, CLOCKS_PER_SEC and CLK_TCK may be either 50 or 60, depending on the system's video frequency setting; they now expand to code that will detect the setting and give the appropriate value.
|
||||
|
||||
p. 353
|
||||
|
||||
The discussion of _exit() should note that the _exit() function is an extension to ANSI C.
|
||||
@ -1198,6 +1202,8 @@ int foo(int[42]);
|
||||
|
||||
158. An "illegal type cast" error would be reported when an illegal operator was used in a constant expression. An appropriate error message is now produced.
|
||||
|
||||
159. The CLOCKS_PER_SEC and CLK_TCK macros were hard-coded as 60, but they should actually be 50 if the system is in 50Hz video mode. This could throw off timing code that used these macros in conjunction with clock(). The macros now expand to code that will detect the video mode and give the appropriate value.
|
||||
|
||||
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
|
||||
|
||||
1. In some situations, fread() reread the first 1K or so of the file.
|
||||
|
Loading…
Reference in New Issue
Block a user