Skip to content

Commit d4f1adf

Browse files
committed
Fixed CFI_SUCCESS and eliminated CFI_FAILURE after asking the standard committee about the proposed changes to the standard.
1 parent a30c312 commit d4f1adf

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

src/iso-fortran-binding/ISO_Fortran_binding.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,17 @@ int CFI_is_contiguous (const CFI_cdesc_t *dv)
383383
for (int i = 0; i < dv->rank; i++)
384384
{
385385
if (dv->dim[i].sm != dv->elem_len)
386-
return CFI_FAILURE;
386+
return 0;
387387
}
388388

389389
/* Allocatable arrays are always contiguous. */
390390
if (dv->attribute == CFI_attribute_allocatable)
391391
{
392-
return CFI_SUCCESS;
392+
return 1;
393393
}
394394
else
395395
{
396-
return CFI_FAILURE;
396+
return 0;
397397
}
398398
}
399399

src/iso-fortran-binding/ISO_Fortran_binding.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,18 @@ extern "C" {
3636
/* Error codes.
3737
CFI_FAILURE and CFI_INVALID_STRIDE should be defined in the standard because they are useful to the implementation of the functions.
3838
*/
39-
#define CFI_FAILURE 0
40-
#define CFI_SUCCESS 1
41-
#define CFI_ERROR_BASE_ADDR_NULL 2
42-
#define CFI_ERROR_BASE_ADDR_NOT_NULL 3
43-
#define CFI_INVALID_ELEM_LEN 4
44-
#define CFI_INVALID_RANK 5
45-
#define CFI_INVALID_TYPE 6
46-
#define CFI_INVALID_ATTRIBUTE 7
47-
#define CFI_INVALID_EXTENT 8
48-
#define CFI_INVALID_STRIDE 9
49-
#define CFI_INVALID_DESCRIPTOR 10
50-
#define CFI_ERROR_MEM_ALLOCATION 11
51-
#define CFI_ERROR_OUT_OF_BOUNDS 12
39+
#define CFI_SUCCESS 0
40+
#define CFI_ERROR_BASE_ADDR_NULL 1
41+
#define CFI_ERROR_BASE_ADDR_NOT_NULL 2
42+
#define CFI_INVALID_ELEM_LEN 3
43+
#define CFI_INVALID_RANK 4
44+
#define CFI_INVALID_TYPE 5
45+
#define CFI_INVALID_ATTRIBUTE 6
46+
#define CFI_INVALID_EXTENT 7
47+
#define CFI_INVALID_STRIDE 8
48+
#define CFI_INVALID_DESCRIPTOR 9
49+
#define CFI_ERROR_MEM_ALLOCATION 10
50+
#define CFI_ERROR_OUT_OF_BOUNDS 11
5251

5352
/* CFI type definitions. */
5453
typedef ptrdiff_t CFI_index_t;

src/tests/unit/iso-fortran-binding/ISO_Fortran_binding_tests.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ int main (void)
462462
elem_len, rank, extents);
463463
tmp_ind = CFI_allocate ((CFI_cdesc_t *) &test7, lower, upper,
464464
base_type_size);
465-
if (tmp_ind != CFI_SUCCESS)
465+
if (tmp_ind != 1)
466466
{
467467
goto next_attribute4;
468468
}
@@ -474,7 +474,7 @@ int main (void)
474474
return 1;
475475
}
476476
else if (ind == CFI_ERROR_BASE_ADDR_NULL && test7.base_addr != NULL &&
477-
tmp_ind != CFI_SUCCESS)
477+
tmp_ind != 1)
478478
{
479479
printf ("CFI_is_contiguous: failed to detect base address is not "
480480
"NULL.\n");

0 commit comments

Comments
 (0)