Mercurial > dwindows
comparison gtk3/dw.c @ 1106:eb6b27d17fe7
Fixed the 64bit warnings in GTK3.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 26 Jul 2011 09:32:50 +0000 |
parents | 8e9db23a8c31 |
children | 36773e04245c |
comparison
equal
deleted
inserted
replaced
1105:e6511648c59e | 1106:eb6b27d17fe7 |
---|---|
2910 GdkCursor *cursor; | 2910 GdkCursor *cursor; |
2911 | 2911 |
2912 DW_MUTEX_LOCK; | 2912 DW_MUTEX_LOCK; |
2913 if(pointertype > 65535) | 2913 if(pointertype > 65535) |
2914 { | 2914 { |
2915 GdkPixbuf *pixbuf = _find_pixbuf((HICN)pointertype, NULL, NULL); | 2915 GdkPixbuf *pixbuf = _find_pixbuf(GINT_TO_POINTER(pointertype), NULL, NULL); |
2916 cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, 8, 8); | 2916 cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, 8, 8); |
2917 } | 2917 } |
2918 else if(!pointertype) | 2918 else if(!pointertype) |
2919 cursor = NULL; | 2919 cursor = NULL; |
2920 else | 2920 else |
5663 * Parameters: | 5663 * Parameters: |
5664 * handle: Handle to icon returned by dw_icon_load(). | 5664 * handle: Handle to icon returned by dw_icon_load(). |
5665 */ | 5665 */ |
5666 void dw_icon_free(HICN handle) | 5666 void dw_icon_free(HICN handle) |
5667 { | 5667 { |
5668 int iicon = (int)handle; | 5668 int iicon = GPOINTER_TO_INT(handle); |
5669 | 5669 |
5670 if(iicon > 65535) | 5670 if(iicon > 65535) |
5671 { | 5671 { |
5672 g_object_unref(handle); | 5672 g_object_unref(handle); |
5673 } | 5673 } |
7525 | 7525 |
7526 while(1) | 7526 while(1) |
7527 { | 7527 { |
7528 FD_ZERO(&rd); | 7528 FD_ZERO(&rd); |
7529 FD_SET(listenfd, &rd); | 7529 FD_SET(listenfd, &rd); |
7530 int result; | |
7530 | 7531 |
7531 maxfd = listenfd; | 7532 maxfd = listenfd; |
7532 | 7533 |
7533 /* Added any connections to the named event semaphore */ | 7534 /* Added any connections to the named event semaphore */ |
7534 for(z=0;z<connectcount;z++) | 7535 for(z=0;z<connectcount;z++) |
7612 /* The semaphore has been posted so | 7613 /* The semaphore has been posted so |
7613 * we tell all the waiting threads to | 7614 * we tell all the waiting threads to |
7614 * continue. | 7615 * continue. |
7615 */ | 7616 */ |
7616 if(array[s].waiting) | 7617 if(array[s].waiting) |
7617 write(array[s].fd, &tmp, 1); | 7618 result = write(array[s].fd, &tmp, 1); |
7618 } | 7619 } |
7619 } | 7620 } |
7620 break; | 7621 break; |
7621 case 2: | 7622 case 2: |
7622 /* Wait */ | 7623 /* Wait */ |
7625 | 7626 |
7626 array[z].waiting = 1; | 7627 array[z].waiting = 1; |
7627 | 7628 |
7628 /* If we are posted exit immeditately */ | 7629 /* If we are posted exit immeditately */ |
7629 if(posted) | 7630 if(posted) |
7630 write(array[z].fd, &tmp, 1); | 7631 result = write(array[z].fd, &tmp, 1); |
7631 } | 7632 } |
7632 break; | 7633 break; |
7633 case 3: | 7634 case 3: |
7634 { | 7635 { |
7635 /* Done Waiting */ | 7636 /* Done Waiting */ |
7692 return NULL; | 7693 return NULL; |
7693 } | 7694 } |
7694 | 7695 |
7695 /* Create a thread to handle this event semaphore */ | 7696 /* Create a thread to handle this event semaphore */ |
7696 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); | 7697 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); |
7697 return (HEV)ev; | 7698 return GINT_TO_POINTER(ev); |
7698 } | 7699 } |
7699 | 7700 |
7700 /* Open an already existing named event semaphore. | 7701 /* Open an already existing named event semaphore. |
7701 * Parameters: | 7702 * Parameters: |
7702 * eve: Pointer to an event handle to receive handle. | 7703 * eve: Pointer to an event handle to receive handle. |
7713 un.sun_family=AF_UNIX; | 7714 un.sun_family=AF_UNIX; |
7714 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); | 7715 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
7715 strcpy(un.sun_path, "/tmp/.dw/"); | 7716 strcpy(un.sun_path, "/tmp/.dw/"); |
7716 strcat(un.sun_path, name); | 7717 strcat(un.sun_path, name); |
7717 connect(ev, (struct sockaddr *)&un, sizeof(un)); | 7718 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
7718 return (HEV)ev; | 7719 return GINT_TO_POINTER(ev); |
7719 } | 7720 } |
7720 | 7721 |
7721 /* Resets the event semaphore so threads who call wait | 7722 /* Resets the event semaphore so threads who call wait |
7722 * on this semaphore will block. | 7723 * on this semaphore will block. |
7723 * Parameters: | 7724 * Parameters: |
7727 int dw_named_event_reset(HEV eve) | 7728 int dw_named_event_reset(HEV eve) |
7728 { | 7729 { |
7729 /* signal reset */ | 7730 /* signal reset */ |
7730 char tmp = (char)0; | 7731 char tmp = (char)0; |
7731 | 7732 |
7732 if((int)eve < 0) | 7733 if(GPOINTER_TO_INT(eve) < 0) |
7733 return 0; | 7734 return DW_ERROR_NONE; |
7734 | 7735 |
7735 if(write((int)eve, &tmp, 1) == 1) | 7736 if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1) |
7736 return 0; | 7737 return DW_ERROR_NONE; |
7737 return 1; | 7738 return DW_ERROR_GENERAL; |
7738 } | 7739 } |
7739 | 7740 |
7740 /* Sets the posted state of an event semaphore, any threads | 7741 /* Sets the posted state of an event semaphore, any threads |
7741 * waiting on the semaphore will no longer block. | 7742 * waiting on the semaphore will no longer block. |
7742 * Parameters: | 7743 * Parameters: |
7747 { | 7748 { |
7748 | 7749 |
7749 /* signal post */ | 7750 /* signal post */ |
7750 char tmp = (char)1; | 7751 char tmp = (char)1; |
7751 | 7752 |
7752 if((int)eve < 0) | 7753 if(GPOINTER_TO_INT(eve) < 0) |
7753 return 0; | 7754 return DW_ERROR_NONE; |
7754 | 7755 |
7755 if(write((int)eve, &tmp, 1) == 1) | 7756 if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1) |
7756 return 0; | 7757 return DW_ERROR_NONE; |
7757 return 1; | 7758 return DW_ERROR_GENERAL; |
7758 } | 7759 } |
7759 | 7760 |
7760 /* Waits on the specified semaphore until it becomes | 7761 /* Waits on the specified semaphore until it becomes |
7761 * posted, or returns immediately if it already is posted. | 7762 * posted, or returns immediately if it already is posted. |
7762 * Parameters: | 7763 * Parameters: |
7770 fd_set rd; | 7771 fd_set rd; |
7771 struct timeval tv, *useme; | 7772 struct timeval tv, *useme; |
7772 int retval = 0; | 7773 int retval = 0; |
7773 char tmp; | 7774 char tmp; |
7774 | 7775 |
7775 if((int)eve < 0) | 7776 if(GPOINTER_TO_INT(eve) < 0) |
7776 return DW_ERROR_NON_INIT; | 7777 return DW_ERROR_NON_INIT; |
7777 | 7778 |
7778 /* Set the timout or infinite */ | 7779 /* Set the timout or infinite */ |
7779 if(timeout == -1) | 7780 if(timeout == -1) |
7780 useme = NULL; | 7781 useme = NULL; |
7785 | 7786 |
7786 useme = &tv; | 7787 useme = &tv; |
7787 } | 7788 } |
7788 | 7789 |
7789 FD_ZERO(&rd); | 7790 FD_ZERO(&rd); |
7790 FD_SET((int)eve, &rd); | 7791 FD_SET(GPOINTER_TO_INT(eve), &rd); |
7791 | 7792 |
7792 /* Signal wait */ | 7793 /* Signal wait */ |
7793 tmp = (char)2; | 7794 tmp = (char)2; |
7794 write((int)eve, &tmp, 1); | 7795 retval = write(GPOINTER_TO_INT(eve), &tmp, 1); |
7795 | 7796 |
7796 retval = select((int)eve+1, &rd, NULL, NULL, useme); | 7797 if(retval == 1) |
7798 retval = select(GPOINTER_TO_INT(eve)+1, &rd, NULL, NULL, useme); | |
7797 | 7799 |
7798 /* Signal done waiting. */ | 7800 /* Signal done waiting. */ |
7799 tmp = (char)3; | 7801 tmp = (char)3; |
7800 write((int)eve, &tmp, 1); | 7802 if(retval == 1) |
7803 retval = write(GPOINTER_TO_INT(eve), &tmp, 1); | |
7801 | 7804 |
7802 if(retval == 0) | 7805 if(retval == 0) |
7803 return DW_ERROR_TIMEOUT; | 7806 return DW_ERROR_TIMEOUT; |
7804 else if(retval == -1) | 7807 else if(retval == -1) |
7805 return DW_ERROR_INTERRUPT; | 7808 return DW_ERROR_INTERRUPT; |
7806 | 7809 |
7807 /* Clear the entry from the pipe so | 7810 /* Clear the entry from the pipe so |
7808 * we don't loop endlessly. :) | 7811 * we don't loop endlessly. :) |
7809 */ | 7812 */ |
7810 read((int)eve, &tmp, 1); | 7813 if(read(GPOINTER_TO_INT(eve), &tmp, 1) == 1) |
7811 return 0; | 7814 return DW_ERROR_NONE; |
7815 return DW_ERROR_GENERAL; | |
7812 } | 7816 } |
7813 | 7817 |
7814 /* Release this semaphore, if there are no more open | 7818 /* Release this semaphore, if there are no more open |
7815 * handles on this semaphore the semaphore will be destroyed. | 7819 * handles on this semaphore the semaphore will be destroyed. |
7816 * Parameters: | 7820 * Parameters: |
7820 int dw_named_event_close(HEV eve) | 7824 int dw_named_event_close(HEV eve) |
7821 { | 7825 { |
7822 /* Finally close the domain socket, | 7826 /* Finally close the domain socket, |
7823 * cleanup will continue in _handle_sem. | 7827 * cleanup will continue in _handle_sem. |
7824 */ | 7828 */ |
7825 close((int)eve); | 7829 close(GPOINTER_TO_INT(eve)); |
7826 return 0; | 7830 return DW_ERROR_NONE; |
7827 } | 7831 } |
7828 | 7832 |
7829 /* | 7833 /* |
7830 * Setup thread independent color sets. | 7834 * Setup thread independent color sets. |
7831 */ | 7835 */ |
7870 { | 7874 { |
7871 free(handle); | 7875 free(handle); |
7872 return NULL; | 7876 return NULL; |
7873 } | 7877 } |
7874 | 7878 |
7875 ftruncate(handle->fd, size); | 7879 if(ftruncate(handle->fd, size)) |
7880 { | |
7881 close(handle->fd); | |
7882 free(handle); | |
7883 return NULL; | |
7884 } | |
7876 | 7885 |
7877 /* attach the shared memory segment to our process's address space. */ | 7886 /* attach the shared memory segment to our process's address space. */ |
7878 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); | 7887 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); |
7879 | 7888 |
7880 if(*dest == MAP_FAILED) | 7889 if(*dest == MAP_FAILED) |