Rate This Document
Findability
Accuracy
Completeness
Readability

Sample 1: 64-Bit Running Mode Check

This sample demonstrates how to use the 64-bit porting pre-check function of the Kunpeng DevKit Affinity Analyzer to port 32-bit applications (compiled using GCC 4.8.5 to 10.3.0) from the x86 platform to the 64-bit platform, perform the porting check, and provide modification suggestions.

  1. Download the sample code from GitHub or Gitee to obtain the software source package.

    The downloaded source package is devkitdemo-main.zip. The ./devkitdemo-main/Porting_advisor/testdemo/precheck/ file extracted from the package is the code to be scanned for 64-bit running mode check.

  2. Log in to the Kunpeng DevKit. In the navigation pane on the left, choose Affinity Analysis > 64-bit Running Mode Check. The page for creating a 64-bit running mode check task is displayed.

    Click Select Folder to upload the precheck folder. See Figure 1.

    Figure 1 64-bit running mode check
  3. Click Check. After the analysis is complete, click View Suggested Source Code on the right of the source file. See Figure 2.
    Figure 2 64-bit mode check report
    In this sample, the precheck folder is used as an example. Table 1 lists the code lines that need to be modified for the porting from the 32-bit platform to 64-bit platform.
    Table 1 Scan result

    File

    Code Line

    Suggestion

    New Code

    func001.c

    Line 26: char a = m;

    Suggestion: // This line needs to be adapted for the 64-bit environment.

    char a = (char)m;

    func001.c

    Line 28: c = c+i;

    c = (char)((int)c +i);

    func002.c

    Line 26: c = p;

    c = (char *)p;

    func003.c

    Line 23: unsigned char *s = c;

    unsigned char *s = (unsigned char *)c;

    func004.c

    Line 25: int q = &a;

    long int q = (long)&a;

    func004.c

    Line 28: p = &a;

    long int p; // Modify line 26:

    p = (long)&a;

    func004.c

    Line 30: test = s;

    long int test = 10; // Modify line 22:

    test = (long)s;

  4. Modify each code line. After the modification is complete, press Ctrl+S to save the modification.
    Figure 3 Modifying the code
  5. Click next to the task name to restart the task. See Figure 4.
    Figure 4 Scan report
  6. Log in to the server, go to the source file directory (for example, /opt/DevKit/workspace/devadmin/affinity/precheck/precheck), and run the make command for the original file. Figure 5 displays the result.
    Figure 5 Running the make command

    Modify the code as required, and run the make command again. Figure 6 shows the result.

    Figure 6 Re-running the make command

    The preceding figure shows that the warnings have been cleared.