fix(examples): fix types on 64-bit cpu support(linux)

Address these:

lock_example.c:162:60: error: cast to pointer from integer of different size
[-Werror=int-to-pointer-cast]
  162 |         xTaskCreatePinnedToCore(inc_num_mutex, NULL, 4096, (void *)thread_id, TASK_PRIO_3, NULL, tskNO_AFFINITY);
      |                                                            ^

create_task_example.c:30:19: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
   30 |     int task_id = (int)arg;
This commit is contained in:
Richard Allen
2026-06-26 22:21:46 -05:00
parent fa8039b5ca
commit c75b7daa3c
2 changed files with 6 additions and 4 deletions
@@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdint.h>
#include "freertos/FreeRTOS.h"
#include "esp_log.h"
#include "basic_freertos_smp_usage.h"
@@ -27,7 +28,7 @@ static void spin_iteration(int spin_iter_num)
static void spin_task(void *arg)
{
// convert arg pointer from void type to int type then dereference it
int task_id = (int)arg;
int task_id = (intptr_t)arg;
ESP_LOGI(TAG, "created task#%d", task_id);
while (!timed_out) {
int core_id = esp_cpu_get_core_id();
@@ -46,7 +47,7 @@ int comp_creating_task_entry_func(int argc, char **argv)
timed_out = false;
// pin 2 tasks on same core and observe in-turn execution,
// and pin another task on the other core to observe "simultaneous" execution
int task_id0 = 0, task_id1 = 1, task_id2 = 2, task_id3 = 3;
intptr_t task_id0 = 0, task_id1 = 1, task_id2 = 2, task_id3 = 3;
xTaskCreatePinnedToCore(spin_task, "pinned_task0_core0", 4096, (void*)task_id0, TASK_PRIO_3, NULL, CORE0);
xTaskCreatePinnedToCore(spin_task, "pinned_task1_core0", 4096, (void*)task_id1, TASK_PRIO_3, NULL, CORE0);
xTaskCreatePinnedToCore(spin_task, "pinned_task2_core1", 4096, (void*)task_id2, TASK_PRIO_3, NULL, CORE1);
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdatomic.h>
#include <stdint.h>
#include "freertos/FreeRTOS.h"
#include "esp_log.h"
#include "esp_timer.h"
@@ -78,7 +79,7 @@ static void inc_num_atomic_iter(void *arg)
static void inc_num_mutex(void *arg)
{
int task_index = (int)arg;
int task_index = (intptr_t)arg;
ESP_LOGI(TAG, "mutex task %d created", task_index);
while (!timed_out) {
@@ -122,7 +123,7 @@ and in turn accessed by multiple tasks. */
int comp_lock_entry_func(int argc, char **argv)
{
s_global_num = 0;
int thread_id;
intptr_t thread_id;
int core_id;
timed_out = false;