ua_architecture_functions.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2018 (c) Jose Cabral, fortiss GmbH
  5. */
  6. #ifdef UA_ARCHITECTURE_POSIX
  7. #include <open62541/types.h>
  8. /* Global malloc singletons */
  9. #ifdef UA_ENABLE_MALLOC_SINGLETON
  10. void * (*UA_globalMalloc)(size_t size) = malloc;
  11. void (*UA_globalFree)(void *ptr) = free;
  12. void * (*UA_globalCalloc)(size_t nelem, size_t elsize) = calloc;
  13. void * (*UA_globalRealloc)(void *ptr, size_t size) = realloc;
  14. #endif
  15. unsigned int UA_socket_set_blocking(UA_SOCKET sockfd){
  16. int opts = fcntl(sockfd, F_GETFL);
  17. if(opts < 0 || fcntl(sockfd, F_SETFL, opts & (~O_NONBLOCK)) < 0)
  18. return UA_STATUSCODE_BADINTERNALERROR;
  19. return UA_STATUSCODE_GOOD;
  20. }
  21. unsigned int UA_socket_set_nonblocking(UA_SOCKET sockfd){
  22. int opts = fcntl(sockfd, F_GETFL);
  23. if(opts < 0 || fcntl(sockfd, F_SETFL, opts | O_NONBLOCK) < 0)
  24. return UA_STATUSCODE_BADINTERNALERROR;
  25. return UA_STATUSCODE_GOOD;
  26. }
  27. void UA_initialize_architecture_network(void){
  28. }
  29. void UA_deinitialize_architecture_network(void){
  30. }
  31. #endif /* UA_ARCHITECTURE_POSIX */