Porting p7zip to IBM mainframe (system z)

Nenad
2013-03-25
2013-05-28
  • Nenad
    Nenad
    2013-03-25

    Hello,

    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
    -D_ISOC99_SOURCE -D_OPEN_THREADS=3 -DPTHREAD_CREATE_JOINABLE=0         
    -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES  -DNDEBUG    
    -D_REENTRANT -DENV_UNIX -DBREAK_HANDLER -DUNICODE -D_UNICODE -c -I.    
    -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                                            
    …                                                                    
    …                                                                    
      +400                                                                 
      +401  typedef unsigned int pthread_t;                                
      +402  typedef unsigned int pthread_key_t;                            
      +403                                                                 
                                                                           
                                                                           
    Going back to the source, the offending line in the C/Threads.c file is
    here:                                                                  
                                                                           
        55  WRes Thread_Close(CThread *thread)                             
        56  {                                                              
        57      if (!thread->_created) return SZ_OK;                       
        58                                                                 
        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.

    Regards.