0

What is the utility of adding ULL in the end of patterns written to test the memory ?

For Exemple

uint64 pattern_55 =  0xAAAAAAAAAAAAAAAAULL;

static error_t  sram_aa_55_test(uint32 start_address, uint32 tested_area_size)
  {
    error_t status = E_NOERROR;

          /*Patterns used to test every SRAM cell */
    uint64 pattern_aa = 0x5555555555555555ULL;
    uint64 pattern_55 = 0xAAAAAAAAAAAAAAAAULL;

          /* Current address being tested */
    uint32 address;

          /* data read back in memory */
    uint64 data_read;

          /* AA pattern test */
    memset((uint64*)start_address, pattern_aa, tested_area_size);
    sync();

    for (address = start_address; address < start_address + tested_area_size; address += sizeof(uint64))
    {
            /* read back the memory cell and check that it contains the same pattern we just wrote */
      data_read = rd_io_64(address);

      if (data_read != pattern_aa)
      {
        return CORE_Test_Error;
      }
    }
  }
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
Hamza
  • 13
  • 1
  • 3
    That's a suffix to the integer marking it as an `unsigned long long`. – Thomas Jager Jul 08 '19 at 13:08
  • Please take some time to read through your books, tutorials or class-notes to see if they mention [integer literal type suffixes](https://en.cppreference.com/w/c/language/integer_constant#The_type_of_the_integer_constant). – Some programmer dude Jul 08 '19 at 13:10
  • If it's available (which it might not be given that non-standard typedefs are used here), `UINT64_C()` should likely be used instead of directly using type integer suffixes. This ensures that the correct size is used, since type sizes can vary between platforms. – Thomas Jager Jul 08 '19 at 13:12
  • @ThomasJager ULL is sufficient however. Actually, no suffix is *required* in this context. – Antti Haapala -- Слава Україні Jul 08 '19 at 13:24

2 Answers2

2

In case of your code snippet it is only for self-commenting the code.

The suffux llu is used for explicit specifying that an integer constant has the type unsigned long long.

However when a constant is presented in the hexadecimal notation the suffix can be omitted because the compiler itself determines the type of the constant. That is (The C Standard, 6.4.4.1 Integer constants)

5 The type of an integer constant is the first of the corresponding list in which its value can be represented.

And for hexadecimal integer constants

int
unsigned int
long int
unsigned long int
long long int
unsigned long long int
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
0

It's a suffix signifying that integer literal is an unsigned long long.

Colin
  • 3,394
  • 1
  • 21
  • 29