@@ -440,7 +440,11 @@ int mq_close( mqd_t mqdes )
440440 else
441441 {
442442 /* Queue not found; bad descriptor. */
443- errno = EBADF ;
443+ #if ( configUSE_POSIX_ERRNO == 1 )
444+ {
445+ errno = EBADF ;
446+ }
447+ #endif
444448 iStatus = -1 ;
445449 }
446450
@@ -479,7 +483,11 @@ int mq_getattr( mqd_t mqdes,
479483 else
480484 {
481485 /* Queue not found; bad descriptor. */
482- errno = EBADF ;
486+ #if ( configUSE_POSIX_ERRNO == 1 )
487+ {
488+ errno = EBADF ;
489+ }
490+ #endif
483491 iStatus = -1 ;
484492 }
485493
@@ -518,7 +526,11 @@ mqd_t mq_open( const char * name,
518526 if ( prvValidateQueueName ( name , & xNameLength ) == pdFALSE )
519527 {
520528 /* Invalid name. */
521- errno = EINVAL ;
529+ #if ( configUSE_POSIX_ERRNO == 1 )
530+ {
531+ errno = EINVAL ;
532+ }
533+ #endif
522534 xMessageQueue = ( mqd_t ) - 1 ;
523535 }
524536
@@ -528,7 +540,11 @@ mqd_t mq_open( const char * name,
528540 if ( ( oflag & O_CREAT ) && ( attr != NULL ) && ( ( attr -> mq_maxmsg <= 0 ) || ( attr -> mq_msgsize <= 0 ) ) )
529541 {
530542 /* Invalid mq_attr.mq_maxmsg or mq_attr.mq_msgsize. */
531- errno = EINVAL ;
543+ #if ( configUSE_POSIX_ERRNO == 1 )
544+ {
545+ errno = EINVAL ;
546+ }
547+ #endif
532548 xMessageQueue = ( mqd_t ) - 1 ;
533549 }
534550 }
@@ -548,7 +564,11 @@ mqd_t mq_open( const char * name,
548564 * O_CREAT and O_EXCL. */
549565 if ( ( oflag & O_EXCL ) && ( oflag & O_CREAT ) )
550566 {
551- errno = EEXIST ;
567+ #if ( configUSE_POSIX_ERRNO == 1 )
568+ {
569+ errno = EEXIST ;
570+ }
571+ #endif
552572 xMessageQueue = ( mqd_t ) - 1 ;
553573 }
554574 else
@@ -557,7 +577,11 @@ mqd_t mq_open( const char * name,
557577 if ( ( ( QueueListElement_t * ) xMessageQueue )-> xPendingUnlink == pdTRUE )
558578 {
559579 /* Queue pending deletion. Don't allow it to be re-opened. */
560- errno = EINVAL ;
580+ #if ( configUSE_POSIX_ERRNO == 1 )
581+ {
582+ errno = EINVAL ;
583+ }
584+ #endif
561585 xMessageQueue = ( mqd_t ) - 1 ;
562586 }
563587 else
@@ -588,13 +612,21 @@ mqd_t mq_open( const char * name,
588612 name ,
589613 xNameLength ) == pdFALSE )
590614 {
591- errno = ENOSPC ;
615+ #if ( configUSE_POSIX_ERRNO == 1 )
616+ {
617+ errno = ENOSPC ;
618+ }
619+ #endif
592620 xMessageQueue = ( mqd_t ) - 1 ;
593621 }
594622 }
595623 else
596624 {
597- errno = ENOENT ;
625+ #if ( configUSE_POSIX_ERRNO == 1 )
626+ {
627+ errno = ENOENT ;
628+ }
629+ #endif
598630 xMessageQueue = ( mqd_t ) - 1 ;
599631 }
600632 }
@@ -651,7 +683,11 @@ ssize_t mq_timedreceive( mqd_t mqdes,
651683 if ( prvFindQueueInList ( NULL , NULL , mqdes ) == pdFALSE )
652684 {
653685 /* Queue not found; bad descriptor. */
654- errno = EBADF ;
686+ #if ( configUSE_POSIX_ERRNO == 1 )
687+ {
688+ errno = EBADF ;
689+ }
690+ #endif
655691 xStatus = -1 ;
656692 }
657693
@@ -661,7 +697,11 @@ ssize_t mq_timedreceive( mqd_t mqdes,
661697 if ( msg_len < ( size_t ) pxMessageQueue -> xAttr .mq_msgsize )
662698 {
663699 /* msg_len too small. */
664- errno = EMSGSIZE ;
700+ #if ( configUSE_POSIX_ERRNO == 1 )
701+ {
702+ errno = EMSGSIZE ;
703+ }
704+ #endif
665705 xStatus = -1 ;
666706 }
667707 }
@@ -675,7 +715,11 @@ ssize_t mq_timedreceive( mqd_t mqdes,
675715
676716 if ( iCalculateTimeoutReturn != 0 )
677717 {
678- errno = iCalculateTimeoutReturn ;
718+ #if ( configUSE_POSIX_ERRNO == 1 )
719+ {
720+ errno = iCalculateTimeoutReturn ;
721+ }
722+ #endif
679723 xStatus = -1 ;
680724 }
681725 }
@@ -694,12 +738,20 @@ ssize_t mq_timedreceive( mqd_t mqdes,
694738 if ( pxMessageQueue -> xAttr .mq_flags & O_NONBLOCK )
695739 {
696740 /* Set errno to EAGAIN for nonblocking mq. */
697- errno = EAGAIN ;
741+ #if ( configUSE_POSIX_ERRNO == 1 )
742+ {
743+ errno = EAGAIN ;
744+ }
745+ #endif
698746 }
699747 else
700748 {
701749 /* Otherwise, set errno to ETIMEDOUT. */
702- errno = ETIMEDOUT ;
750+ #if ( configUSE_POSIX_ERRNO == 1 )
751+ {
752+ errno = ETIMEDOUT ;
753+ }
754+ #endif
703755 }
704756
705757 xStatus = -1 ;
@@ -743,7 +795,11 @@ int mq_timedsend( mqd_t mqdes,
743795 if ( prvFindQueueInList ( NULL , NULL , mqdes ) == pdFALSE )
744796 {
745797 /* Queue not found; bad descriptor. */
746- errno = EBADF ;
798+ #if ( configUSE_POSIX_ERRNO == 1 )
799+ {
800+ errno = EBADF ;
801+ }
802+ #endif
747803 iStatus = -1 ;
748804 }
749805
@@ -753,7 +809,11 @@ int mq_timedsend( mqd_t mqdes,
753809 if ( msg_len > ( size_t ) pxMessageQueue -> xAttr .mq_msgsize )
754810 {
755811 /* msg_len too large. */
756- errno = EMSGSIZE ;
812+ #if ( configUSE_POSIX_ERRNO == 1 )
813+ {
814+ errno = EMSGSIZE ;
815+ }
816+ #endif
757817 iStatus = -1 ;
758818 }
759819 }
@@ -767,7 +827,11 @@ int mq_timedsend( mqd_t mqdes,
767827
768828 if ( iCalculateTimeoutReturn != 0 )
769829 {
770- errno = iCalculateTimeoutReturn ;
830+ #if ( configUSE_POSIX_ERRNO == 1 )
831+ {
832+ errno = iCalculateTimeoutReturn ;
833+ }
834+ #endif
771835 iStatus = -1 ;
772836 }
773837 }
@@ -785,7 +849,11 @@ int mq_timedsend( mqd_t mqdes,
785849 if ( xSendData .pcData == NULL )
786850 {
787851 /* msg_len too large. */
788- errno = EMSGSIZE ;
852+ #if ( configUSE_POSIX_ERRNO == 1 )
853+ {
854+ errno = EMSGSIZE ;
855+ }
856+ #endif
789857 iStatus = -1 ;
790858 }
791859 else
@@ -806,12 +874,20 @@ int mq_timedsend( mqd_t mqdes,
806874 if ( pxMessageQueue -> xAttr .mq_flags & O_NONBLOCK )
807875 {
808876 /* Set errno to EAGAIN for nonblocking mq. */
809- errno = EAGAIN ;
877+ #if ( configUSE_POSIX_ERRNO == 1 )
878+ {
879+ errno = EAGAIN ;
880+ }
881+ #endif
810882 }
811883 else
812884 {
813885 /* Otherwise, set errno to ETIMEDOUT. */
814- errno = ETIMEDOUT ;
886+ #if ( configUSE_POSIX_ERRNO == 1 )
887+ {
888+ errno = ETIMEDOUT ;
889+ }
890+ #endif
815891 }
816892
817893 /* Free the allocated queue data. */
@@ -840,7 +916,11 @@ int mq_unlink( const char * name )
840916 if ( prvValidateQueueName ( name , & xNameSize ) == pdFALSE )
841917 {
842918 /* Error with mq name. */
843- errno = EINVAL ;
919+ #if ( configUSE_POSIX_ERRNO == 1 )
920+ {
921+ errno = EINVAL ;
922+ }
923+ #endif
844924 iStatus = -1 ;
845925 }
846926
@@ -873,7 +953,11 @@ int mq_unlink( const char * name )
873953 else
874954 {
875955 /* The named message queue doesn't exist. */
876- errno = ENOENT ;
956+ #if ( configUSE_POSIX_ERRNO == 1 )
957+ {
958+ errno = ENOENT ;
959+ }
960+ #endif
877961 iStatus = -1 ;
878962 }
879963
0 commit comments