Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
A
angle
  • Project
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Chen Yisong
  • angle
  • Repository

Switch branch/tag
  • angle
  • src
  • common
  • debug.h
Find file
BlameHistoryPermalink
  • Shahbaz Youssefi's avatar
    Add compiler printf attribute to relevant functions · a390ebd9
    Shahbaz Youssefi authored Oct 18, 2018
    Relands 27a472c6 with reinterpret_cast changed to C-style cast to
    support types that are pointers on some platforms and integers on
    others.
    
    This commit includes fixes to undefined behavior caught by this
    attribute.  The following changes have been made:
    
    - 0x%0.8p is changed to %016 PRIxPTR. Both 0 and . have undefined
      behavior with p.  Additionally, %p already prints 0x with both gcc and
      clang.  This results in a small output change:
    
        void *x = (void *)0x1234;
        void *y = (void *)0x1234567890abcdef;
    
        printf("|%0.8p|\n", x);
        printf("|%0.8p|\n", y);
    
        printf("|%016" PRIxPTR "|\n", (uintptr_t)x);
        printf("|%016" PRIxPTR "|\n", (uintptr_t)y);
    
      prints:
    
        |0x00001234|
        |0x1234567890abcdef|
        |0x0000000000001234|
        |0x1234567890abcdef|
    
    - %d used for GLintptr, GLsizeiptr, EGLTime and EGLnsecsANDROID is
      changed to %llu and the relevant argument is cast to unsigned long
      long.  This is due to these types being typedefs to unknown types (on
      Linux for example, these are unsigned long, and my guess would be
      unsigned long long on Windows where long is 32 bits).
    - %llu is used for GLuint64, which could be unsigned long (as is on
      Linux).  Those arguments are cast to unsigned long long.
    - %p is used for some EGLNative types, but those types may not be a
      pointer.  Those arguments are cast to uintptr_t and printed as above.
    
    Bug: angleproject:2928
    Change-Id: Idf9f705c3d00f69e41e7603453016276a2e13a64
    Reviewed-on: https://chromium-review.googlesource.com/c/1300913Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
    Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
    a390ebd9
debug.h 11.5 KB
EditWeb IDE
×

Replace debug.h

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.