Changeset fd882ee in rtems
- Timestamp:
- 11/02/99 15:29:47 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- d80188eb
- Parents:
- 26c828f
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/posix/src/semaphore.c
r26c828f rfd882ee 62 62 _Thread_Disable_dispatch(); 63 63 64 /* Sharing semaphores among processes is not currently supported */ 65 if (pshared != 0) { 66 _Thread_Enable_dispatch(); 67 set_errno_and_return_minus_one( ENOSYS ); 68 } 69 64 70 the_semaphore = _POSIX_Semaphore_Allocate(); 65 71 66 72 if ( !the_semaphore ) { 67 73 _Thread_Enable_dispatch(); 68 set_errno_and_return_minus_one( ENO MEM);74 set_errno_and_return_minus_one( ENOSPC ); 69 75 } 70 76 … … 97 103 98 104 the_sem_attr->discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; 99 105 106 /* 107 * This effectively disables limit checking. 108 */ 109 110 the_sem_attr->maximum_count = 0xFFFFFFFF; 111 100 112 _CORE_semaphore_Initialize( 101 113 &the_semaphore->Semaphore, … … 244 256 Objects_Id the_semaphore_id; 245 257 POSIX_Semaphore_Control *the_semaphore; 258 Objects_Locations location; 246 259 247 260 248 261 if ( oflag & O_CREAT ) { 249 262 va_start(arg, oflag); 250 mode = (mode_t) va_arg( arg, mode_t * ); 251 value = (unsigned int) va_arg( arg, unsigned int * ); 263 /*mode = (mode_t) va_arg( arg, mode_t * );*/ 264 mode = va_arg( arg, mode_t ); 265 /*value = (unsigned int) va_arg( arg, unsigned int * );*/ 266 value = va_arg( arg, unsigned int ); 252 267 va_end(arg); 253 268 } … … 271 286 } 272 287 /* some type of error */ 273 set_errno_and_return_minus_one_cast( status, sem_t * );288 /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ 274 289 275 290 } else { /* name -> ID translation succeeded */ … … 284 299 */ 285 300 301 the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); 286 302 the_semaphore->open_count += 1; 287 303 … … 298 314 status = _POSIX_Semaphore_Create_support( 299 315 name, 300 TRUE, /*shared across processes */316 FALSE, /* not shared across processes */ 301 317 value, 302 318 &the_semaphore … … 432 448 register POSIX_Semaphore_Control *the_semaphore; 433 449 Objects_Locations location; 450 int code; 434 451 435 452 the_semaphore = _POSIX_Semaphore_Get( sem, &location ); … … 449 466 ); 450 467 _Thread_Enable_dispatch(); 451 return _Thread_Executing->Wait.return_code; 468 code = _Thread_Executing->Wait.return_code; 469 switch (_Thread_Executing->Wait.return_code) { 470 case 1: 471 errno = EAGAIN; 472 code = -1; 473 break; 474 case 3: 475 errno = ETIMEDOUT; 476 code = -1; 477 break; 478 } 479 480 /*return _Thread_Executing->Wait.return_code;*/ 481 return code; 452 482 } 453 483 return POSIX_BOTTOM_REACHED(); … … 574 604 return POSIX_BOTTOM_REACHED(); 575 605 } 606 607 /*PAGE 608 * 609 * _POSIX_Semaphore_Name_to_id 610 * 611 * XXX 612 */ 613 614 int _POSIX_Semaphore_Name_to_id( 615 const char *name, 616 Objects_Id *id 617 ) 618 { 619 Objects_Name_to_id_errors status; 620 621 status = _Objects_Name_to_id( &_POSIX_Semaphore_Information, name, 0, id ); 622 623 if ( status == OBJECTS_SUCCESSFUL ) { 624 return 0; 625 } else { 626 return EINVAL; 627 } 628 } 629 -
cpukit/posix/src/semaphore.c
r26c828f rfd882ee 62 62 _Thread_Disable_dispatch(); 63 63 64 /* Sharing semaphores among processes is not currently supported */ 65 if (pshared != 0) { 66 _Thread_Enable_dispatch(); 67 set_errno_and_return_minus_one( ENOSYS ); 68 } 69 64 70 the_semaphore = _POSIX_Semaphore_Allocate(); 65 71 66 72 if ( !the_semaphore ) { 67 73 _Thread_Enable_dispatch(); 68 set_errno_and_return_minus_one( ENO MEM);74 set_errno_and_return_minus_one( ENOSPC ); 69 75 } 70 76 … … 97 103 98 104 the_sem_attr->discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; 99 105 106 /* 107 * This effectively disables limit checking. 108 */ 109 110 the_sem_attr->maximum_count = 0xFFFFFFFF; 111 100 112 _CORE_semaphore_Initialize( 101 113 &the_semaphore->Semaphore, … … 244 256 Objects_Id the_semaphore_id; 245 257 POSIX_Semaphore_Control *the_semaphore; 258 Objects_Locations location; 246 259 247 260 248 261 if ( oflag & O_CREAT ) { 249 262 va_start(arg, oflag); 250 mode = (mode_t) va_arg( arg, mode_t * ); 251 value = (unsigned int) va_arg( arg, unsigned int * ); 263 /*mode = (mode_t) va_arg( arg, mode_t * );*/ 264 mode = va_arg( arg, mode_t ); 265 /*value = (unsigned int) va_arg( arg, unsigned int * );*/ 266 value = va_arg( arg, unsigned int ); 252 267 va_end(arg); 253 268 } … … 271 286 } 272 287 /* some type of error */ 273 set_errno_and_return_minus_one_cast( status, sem_t * );288 /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ 274 289 275 290 } else { /* name -> ID translation succeeded */ … … 284 299 */ 285 300 301 the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); 286 302 the_semaphore->open_count += 1; 287 303 … … 298 314 status = _POSIX_Semaphore_Create_support( 299 315 name, 300 TRUE, /*shared across processes */316 FALSE, /* not shared across processes */ 301 317 value, 302 318 &the_semaphore … … 432 448 register POSIX_Semaphore_Control *the_semaphore; 433 449 Objects_Locations location; 450 int code; 434 451 435 452 the_semaphore = _POSIX_Semaphore_Get( sem, &location ); … … 449 466 ); 450 467 _Thread_Enable_dispatch(); 451 return _Thread_Executing->Wait.return_code; 468 code = _Thread_Executing->Wait.return_code; 469 switch (_Thread_Executing->Wait.return_code) { 470 case 1: 471 errno = EAGAIN; 472 code = -1; 473 break; 474 case 3: 475 errno = ETIMEDOUT; 476 code = -1; 477 break; 478 } 479 480 /*return _Thread_Executing->Wait.return_code;*/ 481 return code; 452 482 } 453 483 return POSIX_BOTTOM_REACHED(); … … 574 604 return POSIX_BOTTOM_REACHED(); 575 605 } 606 607 /*PAGE 608 * 609 * _POSIX_Semaphore_Name_to_id 610 * 611 * XXX 612 */ 613 614 int _POSIX_Semaphore_Name_to_id( 615 const char *name, 616 Objects_Id *id 617 ) 618 { 619 Objects_Name_to_id_errors status; 620 621 status = _Objects_Name_to_id( &_POSIX_Semaphore_Information, name, 0, id ); 622 623 if ( status == OBJECTS_SUCCESSFUL ) { 624 return 0; 625 } else { 626 return EINVAL; 627 } 628 } 629
Note: See TracChangeset
for help on using the changeset viewer.