Overview
Comment: | Remove remaining uses of lrint()
It was used to convert a time interval into seconds and microseconds or |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e702135e17e116c2ee57b6eff96b7ef9 |
User & Date: | js on 2019-09-01 16:53:45 |
Other Links: | manifest | tags |
Context
2019-09-01
| ||
18:22 | Add +[OFThread isMainThread] check-in: 8a2fa8eff4 user: js tags: trunk | |
16:53 | Remove remaining uses of lrint() check-in: e702135e17 user: js tags: trunk | |
15:29 | OFThread: Allow specifying a name before starting check-in: 77780c7596 user: js tags: trunk | |
Changes
Modified src/OFKqueueKernelEventObserver.m from [436780f050] to [9e8a185a40].
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #include "config.h" #include <assert.h> #include <errno.h> | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #include "config.h" #include <assert.h> #include <errno.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif #include "unistd_wrapper.h" #include <sys/types.h> |
︙ | ︙ | |||
161 162 163 164 165 166 167 | [self of_processQueue]; if ([self of_processReadBuffers]) return; timeout.tv_sec = (time_t)timeInterval; | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | [self of_processQueue]; if ([self of_processReadBuffers]) return; timeout.tv_sec = (time_t)timeInterval; timeout.tv_nsec = (timeInterval - timeout.tv_sec) * 1000000000; events = kevent(_kernelQueue, NULL, 0, eventList, EVENTLIST_SIZE, (timeInterval != -1 ? &timeout : NULL)); if (events < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; |
︙ | ︙ |
Modified src/OFSelectKernelEventObserver.m from [fa45b767a1] to [6eb8060c59].
︙ | ︙ | |||
23 24 25 26 27 28 29 | #ifdef OF_WINDOWS /* Win32 has a ridiculous default of 64, even though it supports much more. */ # define FD_SETSIZE 1024 #endif #include <errno.h> | < | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #ifdef OF_WINDOWS /* Win32 has a ridiculous default of 64, even though it supports much more. */ # define FD_SETSIZE 1024 #endif #include <errno.h> #include <string.h> #include <sys/time.h> #import "OFSelectKernelEventObserver.h" #import "OFArray.h" #import "OFKernelEventObserver+Private.h" |
︙ | ︙ | |||
176 177 178 179 180 181 182 | * satisfy the required range, we just cast to int. */ #ifndef OF_WINDOWS timeout.tv_sec = (time_t)timeInterval; #else timeout.tv_sec = (long)timeInterval; #endif | | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | * satisfy the required range, we just cast to int. */ #ifndef OF_WINDOWS timeout.tv_sec = (time_t)timeInterval; #else timeout.tv_sec = (long)timeInterval; #endif timeout.tv_usec = (int)((timeInterval - timeout.tv_sec) * 1000); #ifdef OF_AMIGAOS if ((cancelSignal = AllocSignal(-1)) == (ULONG)-1) @throw [OFObserveFailedException exceptionWithObserver: self errNo: EAGAIN]; execSignalMask = _execSignalMask | (1ul << cancelSignal); |
︙ | ︙ |
Modified src/OFThread.m from [67276b0c18] to [590ace3cab].
︙ | ︙ | |||
82 83 84 85 86 87 88 | # import "OFThreadStillRunningException.h" #endif #ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif | < < < < | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | # import "OFThreadStillRunningException.h" #endif #ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif #if defined(OF_HAVE_THREADS) # import "tlskey.h" # if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) # import "socket.h" # endif static of_tlskey_t threadSelfKey; |
︙ | ︙ | |||
246 247 248 249 250 251 252 | @throw [OFOutOfRangeException exception]; svcSleepThread((int64_t)(timeInterval * 1000000000)); #elif defined(HAVE_NANOSLEEP) struct timespec rqtp; rqtp.tv_sec = (time_t)timeInterval; | | | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | @throw [OFOutOfRangeException exception]; svcSleepThread((int64_t)(timeInterval * 1000000000)); #elif defined(HAVE_NANOSLEEP) struct timespec rqtp; rqtp.tv_sec = (time_t)timeInterval; rqtp.tv_nsec = (timeInterval - rqtp.tv_sec) * 1000000000; if (rqtp.tv_sec != trunc(timeInterval)) @throw [OFOutOfRangeException exception]; nanosleep(&rqtp, NULL); #elif defined(OF_AMIGAOS) if (timeInterval * 50 > ULONG_MAX) |
︙ | ︙ | |||
271 272 273 274 275 276 277 | while (counter--) swiWaitForVBlank(); #else if (timeInterval > UINT_MAX) @throw [OFOutOfRangeException exception]; sleep((unsigned int)timeInterval); | | | | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | while (counter--) swiWaitForVBlank(); #else if (timeInterval > UINT_MAX) @throw [OFOutOfRangeException exception]; sleep((unsigned int)timeInterval); usleep((unsigned int) (timeInterval - (unsigned int)timeInterval) * 1000000); #endif } + (void)sleepUntilDate: (OFDate *)date { [self sleepForTimeInterval: date.timeIntervalSinceNow]; } |
︙ | ︙ |
Modified src/condition_pthread.m from [953df43013] to [1c18f916fb].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ | < < | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ bool of_condition_new(of_condition_t *condition) { return (pthread_cond_init(condition, NULL) == 0); } bool |
︙ | ︙ | |||
44 45 46 47 48 49 50 | bool of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex, of_time_interval_t timeout) { struct timespec ts; ts.tv_sec = (time_t)timeout; | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | bool of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex, of_time_interval_t timeout) { struct timespec ts; ts.tv_sec = (time_t)timeout; ts.tv_nsec = (timeout - ts.tv_sec) * 1000000000; return (pthread_cond_timedwait(condition, mutex, &ts) == 0); } bool of_condition_free(of_condition_t *condition) { return (pthread_cond_destroy(condition) == 0); } |