Porting p7zip to IBM mainframe (system z)

  • Nenad


    need help with the following error when building on z/OS (1.12):

    I was able to build the C++ object files from p7zip, but stuck with    
    building Threads.c file:                                               
    /c390/archive/zosv1r13/dataset/xlc -O -s -qlonglong -D_XOPEN_SOURCE=500
    -I../../../../C -I../../../myWindows -I../../../include_windows        
    -I../../.. ../../../../C/Threads.c  -D_NO_PROTO                        
    ERROR CCN3068 <source file>:<line number>    Operation between types   
    "struct {…}" and "int" is not allowed.                               
    The reason for failure:  implementation of pthread_t is platform       
    specific and the p7zip code is written in such a way that it works on  
    AIX/Linux, but it probably requires some porting efforts to make it work
    on z/OS.                                                               
    Particularly, on z/OS (and from what I read on forums it is valid for  
    FreeBSD Unix) pthread_t declaration is done via structure:             
    vi /usr/include/sys/types.h                                            
       280         #ifndef __pthread_t                                     
       281            #define __pthread_t  1                               
       282            typedef struct {                                     
       283                       char __;                            
       284            } pthread_t;                                         
       285         #endif                                                  
    vs AIX (and Linux) type of OS which declares pthread_t as of type      
    unsigned int:                                                          
    vi /usr/include/sys/types.h                                            
      +401  typedef unsigned int pthread_t;                                
      +402  typedef unsigned int pthread_key_t;                            
    Going back to the source, the offending line in the C/Threads.c file is
        55  WRes Thread_Close(CThread *thread)                             
        56  {                                                              
        57      if (!thread->_created) return SZ_OK;                       
        59      thread->_tid = B_BAD_THREAD_ID;     <--- An error is coming
    from here                                                              
        60      thread->_created = 0;                                      
        61      return SZ_OK;                                              
        62  }                                                              
    where _tid is earlier declared as of type pthread_t:                   
    #line 19 "../../../../C/Threads.h"                                     
    typedef struct _CThread                                                
    #line 24                                                               
            pthread_t _tid;                                                
            int _created;                                                  
    } CThread;                                                             

    Any help will be appreciated.